Skip to content

Instantly share code, notes, and snippets.

@djsmith42
Created January 4, 2020 22:56
Show Gist options
  • Save djsmith42/4b5993d20c759611cc7a0bea21b99958 to your computer and use it in GitHub Desktop.
Save djsmith42/4b5993d20c759611cc7a0bea21b99958 to your computer and use it in GitHub Desktop.
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