Skip to content

Instantly share code, notes, and snippets.

@C00kiie
Last active Feb 8, 2019
Embed
What would you like to do?
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