Skip to content

Instantly share code, notes, and snippets.

@C00kiie
Last active February 8, 2019 08:41
Show Gist options
  • Save C00kiie/2fa7ca0f4473c703f01a6dff40df7986 to your computer and use it in GitHub Desktop.
Save C00kiie/2fa7ca0f4473c703f01a6dff40df7986 to your computer and use it in GitHub Desktop.
circular squad
def winner(n):
"""return the number of person who wins"""
persons = list(range(1, n + 1))
while len(persons) > 1:
for index, _ in enumerate(persons):
del persons[(index + 1) % len(persons)]
return persons[0]
m1 = winner(2468)
m2 = winner(2049)
m3 = winner(13892)
print(m1)
print(m2)
print(m3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment