Tower Breakers

  • + 0 comments
            // Write your code here
            /*
                If m == 1, the towers are all of height 1
                -> No moves possible
                -> Player 1 loses, so return 2
    
                If n is even, whatever move Player 1 makes,
                -> Player 2 can mirror it on another tower
                -> Player 2 wins -> return 2
    
                If n is odd and m > 1,
                -> Player 1 can always win
                -> return 1
            */
            if(m == 1 || n%2 == 0)
            {
                return 2 ;
            }else{
                return 1 ;
            }
        }