Created
November 1, 2016 20:53
-
-
Save mmasztalerczuk/c7bfd473245c5d87174322d653c14de3 to your computer and use it in GitHub Desktop.
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 count(a): | |
return len(bin(a)[2:].replace("0", "")) | |
class ThueMorseGame: | |
def get(self, n, m): | |
last = 0 | |
i = 0 | |
while i <= n: | |
if count(i)%2 == 1: | |
i += 1 | |
else: | |
last = i | |
i += m + 1 | |
return "Bob" if last == n else "Alice" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment