Created
January 4, 2020 22:56
-
-
Save djsmith42/4b5993d20c759611cc7a0bea21b99958 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
for player_count in range(1, 10000): | |
got_to_play = set() | |
direction = 1 | |
player = 0 | |
for n in range(1, 1000000): | |
got_to_play.add(player) | |
if got_to_play == set(range(player_count)): | |
break | |
if n % 7 == 0 and n % 8 == 0: # flip flop | |
direction = -direction | |
player += direction # skip 1 player | |
elif n % 7 == 0: # flip | |
player += direction # skip 1 player | |
elif n % 8 == 0: # flop | |
direction = -direction | |
player += direction | |
# wrap players in the circle: | |
if player >= player_count: | |
player = 0 | |
elif player < 0: | |
player = player_count - 1 | |
did_not_get_to_play = sorted(set(range(player_count)) - got_to_play) | |
if did_not_get_to_play: | |
print('With {} players, these {} players played: {}'.format(player_count, len(got_to_play), sorted(got_to_play))) | |
else: | |
print('With {} players, ALL players played'.format(player_count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment