Skip to content

Instantly share code, notes, and snippets.

@djsmith42
Created January 4, 2020 23:22
Show Gist options
  • Save djsmith42/1231386f73fbed05cacdd8a639010183 to your computer and use it in GitHub Desktop.
Save djsmith42/1231386f73fbed05cacdd8a639010183 to your computer and use it in GitHub Desktop.
FLIP = 7
FLOP = 8
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 % FLIP == 0:
direction = -direction
elif n % FLOP == 0:
player += direction # skip 1 player
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))
~/Dev/Sandbox  python flipflop.py
With 1 players, ALL players played
With 2 players, ALL players played
With 3 players, ALL players played
With 4 players, ALL players played
With 5 players, ALL players played
With 6 players, ALL players played
With 7 players, ALL players played
With 8 players, ALL players played
With 9 players, ALL players played
With 10 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 8, 9]
With 11 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 9, 10]
With 12 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 10, 11]
With 13 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 11, 12]
With 14 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 12, 13]
With 15 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 13, 14]
With 16 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 14, 15]
With 17 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 15, 16]
With 18 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 16, 17]
With 19 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 17, 18]
With 20 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 18, 19]
With 21 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 19, 20]
With 22 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 20, 21]
With 23 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 21, 22]
With 24 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 22, 23]
With 25 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 23, 24]
With 26 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 24, 25]
With 27 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 25, 26]
With 28 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 26, 27]
With 29 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 27, 28]
With 30 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 28, 29]
With 31 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 29, 30]
With 32 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 30, 31]
With 33 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 31, 32]
With 34 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 32, 33]
With 35 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 33, 34]
With 36 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 34, 35]
With 37 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 35, 36]
With 38 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 36, 37]
With 39 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 37, 38]
With 40 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 38, 39]
With 41 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 39, 40]
With 42 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 40, 41]
With 43 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 41, 42]
With 44 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 42, 43]
With 45 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 43, 44]
With 46 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 44, 45]
With 47 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 45, 46]
With 48 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 46, 47]
With 49 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 47, 48]
With 50 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 48, 49]
With 51 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 49, 50]
With 52 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 50, 51]
With 53 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 51, 52]
With 54 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 52, 53]
With 55 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 53, 54]
With 56 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 54, 55]
With 57 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 55, 56]
With 58 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 56, 57]
With 59 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 57, 58]
With 60 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 58, 59]
With 61 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 59, 60]
With 62 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 60, 61]
With 63 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 61, 62]
With 64 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 62, 63]
With 65 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 63, 64]
With 66 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 64, 65]
With 67 players, these 9 players played: [0, 1, 2, 3, 4, 5, 6, 65, 66]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment