• + 0 comments

    Not the most efficient, but is readable and works

    def counterGame(n):
        powers2 = []
        x = 2
        while x<=n:
            powers2.append(x)
            x *= 2
    
        louise = True
        while True:
            if n == 1:
                break
            n = n / 2 if n == powers2[-1] else n - powers2[-1]
            powers2 = [x for x in powers2 if x <= n]
            louise = not louise
        return "Richard" if louise else "Louise"