-
-
Save orlp/f9b949d60c766430fe9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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