Tower Breakers

Sort by

recency

|

112 Discussions

|

  • + 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;
    
  • + 1 comment

    no need to tell you how awful this problem description was, they even gave a contradicting example with the description of the "rules",

    "1 <= y < x where y EVENLY DIVIDES x" then proceeds to give an example about only 2 choices when m = 6, y =3 or y= 5 to leave 1, then how is 5 is a valid choice, thank you for your time but please respect our little brains

  • + 0 comments

    C# SOLUTION

    if (n == 1) return 1; if (m == 1) return 2;

        return (n%2==0) ? 2 : 1;
    
  • + 0 comments

    Here is - HackerRank Tower Breakers problem solution

  • + 2 comments

    This is one of the more awfully written and described questions I have seen on this platform.

    1. Player 1 in the example clearly had more than the 2 moves. How about 4 % 2 == 0?
    2. Players lose if there is 1 block remaining. But why is 1 % 0 == 0 not possible again?
    3. Every player can remove all but 1 block, and this greedy approach just gives you a pre-determined winner every time.

    If m == 1 and player 1 starts, then apparently player 1 does not have any remaining moves and player 2 wins??