Last active
February 8, 2019 08:41
-
-
Save C00kiie/2fa7ca0f4473c703f01a6dff40df7986 to your computer and use it in GitHub Desktop.
circular squad
This file contains hidden or 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
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