Counter game

  • + 0 comments
    def counterGame(n):
        # Write your code here
        turns = 0
        while n > 1:
            if(n&(n-1) == 0):
                n//=2
            else:
                highest_power_of_2 = 1
                while highest_power_of_2*2<=n:
                    highest_power_of_2*=2
                n-=highest_power_of_2
            turns += 1
        if turns %2 == 0:
            return "Richard"
        else:
            return "Louise"