Skip to content

Instantly share code, notes, and snippets.

@orlp orlp/gist:f9b949d60c766430fe9c Secret
Last active Aug 29, 2015

Embed
What would you like to do?
import random
import math
def init_game():
global stack, wallet, max_taken, remaining
stack = list(range(1, 10001))
random.shuffle(stack)
wallet = max_taken = 0
def read():
return stack[0]
def take():
global wallet, max_taken
amount = stack.pop(0)
if amount > max_taken:
wallet += amount
max_taken = amount
def pass_envelope():
stack.pop(0)
def test(algo):
init_game()
for i in range(10000):
algo()
return wallet
def algo_dennis():
global turns
turns -= 1
if read() > turns:
take()
else:
pass_envelope()
s = []
for i in range(51):
turns = 10001
s.append(test(algo_dennis))
print(list(sorted(s))[25])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.