circular squad
This file contains 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