You're in the casino, playing Roulette, going for the "1-18" bets only and desperate to beat the house and so you want to test how effective the [Martingale strategy](https://en.wikipedia.org/wiki/Martingale_(betting_system)) is. 

You will be given a starting cash balance and an array of binary digits to represent a win (`1`) or a loss (`0`). Return your balance after playing all rounds.


*The Martingale strategy*

You start with a stake of `100` dollars. If you lose a round, you lose the stake placed on that round and you double the stake for your next bet. When you win, you win 100% of the stake and revert back to staking 100 dollars on your next bet.


## Example
```
martingale(1000, [1, 1, 0, 0, 1]) === 1300
```
Explanation:
* you win your 1st round: gain $100, balance = 1100
* you win the 2nd round: gain $100, balance = 1200
* you lose the 3rd round: lose $100 dollars, balance = 1100
* double stake for 4th round and lose: staked $200, lose $200, balance = 900
* double stake for 5th round and win: staked $400, won $400, balance = 1300

**Note: Your balance is allowed to go below 0.**

Difficulty: introductory

Starter code:

def martingale(bank, outcomes):
	

Solutions:
def martingale(bank, outcomes):
    stake = 100
    for i in outcomes:
        if i == 0:
            bank -= stake
            stake *= 2
        else:
            bank += stake
            stake = 100
    return bank

def martingale(bank, outcomes):
    bet=100
    for results in outcomes:
        if not bool(results):
            bank= bank -bet
            bet*=2
        if bool(results):
            bank=bank+bet
            bet=100
    return bank

def martingale(bank, outcomes):
    nxt = 100
    for result in outcomes:
        if result:
            bank += nxt
            nxt = 100
        else:
            bank -= nxt
            nxt *= 2
    return bank

def martingale(n, a, m=100):
    return sum((y := x and m or -m) and (m := x and 100 or m * 2) and y for x in a) + n

def martingale(bank, outcomes):
    loss=win=0
    stake=100
    for i in outcomes:
        if i==1:
            bank+=stake
            if stake!=100:
                stake=100
        else:
            bank-=stake
            stake*=2
    return bank
    #beat the house here...


def martingale(bank, outcomes, rate = 100):
    for i in outcomes:
        bank -= rate
        if i:
            bank += rate*2
            rate = 100
        else:
            rate *= 2
    return bank

def martingale(bankRoll, outcomes):
    baseBet = 100
    betMultiplier = 1

    for i in outcomes:
        if i:   #we won: Update our bank roll, reset our bet to the base case of 100
            bankRoll += betMultiplier*baseBet 
            betMultiplier = 1
        else: #we lost: Update our bank roll,  double our previous bet
            bankRoll -= betMultiplier*baseBet
            betMultiplier *= 2

    return bankRoll
#end martingale function


BASE_BET = 100

def martingale(bank, outcomes, bet = BASE_BET):
    for win in outcomes:
        if win:
            bank += bet
            bet = BASE_BET
        else:
            bank -= bet
            bet *= 2
    
    return bank

def martingale(bank, outcomes):
    balance = bank
    stake = 100
    for win in outcomes:
        if win:
            balance += stake
            stake = 100
        else:
            balance -= stake
            stake *= 2
    return balance


def martingale(bank, outcomes):
    risking = 100
    for outcome in outcomes:
        if outcome == 0:
            bank -= risking
            risking *= 2
        if outcome == 1:
            bank += risking
            risking = 100
    return bank