You are viewing a single comment's thread. Return to all comments →
#Python 3 def counterGame(n): turns = 0 while n > 1: power = 1 << (n.bit_length() - 1) #uses bit length to quickly calculate the largest power of 2 <= n if n == power: n >>=1 #use a bit shift to quickly divide by 2 else: n -= power turns += 1 return "Louise" if turns %2 != 0 else "Richard"
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →