Tower Breakers

  • + 0 comments

    Solution that worked for me with an assumption that player 2 always mirrors player 1's moves:(if someone understands why we should assume that please explain)

    if (m == 1) { return 2; }

        // If there are an odd number of towers, Player 1 wins
        // If there are an even number of towers, Player 2 wins
        return (n % 2 == 1) ? 1 : 2;