Tower Breakers

  • + 1 comment

    This can be solved quite simply following this logic.

    If n is even, player 2 will create pairs of towers, such that whenever player 1 moves, they make the same move on the towers pair. Since the number of towers is even, this will always result in them winning.

    Alternatively, in n is odd, then player 2 only wins if the height of the tower is 1

    def towerBreakers(n, m):
        # Write your code here
        return 2 if (n % 2 == 0 or m == 1) else 1