Skip to content

Instantly share code, notes, and snippets.

@markusleh
Created February 7, 2019 17:09
Show Gist options
  • Save markusleh/082680a1d8ad986ed7235b9f326e032a to your computer and use it in GitHub Desktop.
Save markusleh/082680a1d8ad986ed7235b9f326e032a to your computer and use it in GitHub Desktop.
import random
import math
value = random.randrange(0, 2)
vals = []
rounds = 1000
for i in range(0,rounds):
vals.append(random.randrange(0,2))
avg = sum(vals)/len(vals)
print("Avg: {}".format(avg))
# Game
money = 10
start_bet = 1
guess = 2
bet = False
curr_bet = money
bet_count = 0
for i in range(0,rounds):
if bet == True:
bet_count += 1
bet = False
if vals[i] == 1:
money = money + curr_bet
else:
money -= curr_bet
curr_bet *= 2
continue
if vals[i-guess:i] == [1,1]:
bet = True
print("Final score: {}".format(money))
print("Bets made: {}".format(bet_count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment