Tower Breakers

Sort by

recency

|

115 Discussions

|

  • + 0 comments

    My Javascript solution

    function towerBreakers(n, m) {
        // Write your code here
        return (m === 1 || n%2 === 0) ? 2 : 1
    }
    
  • + 0 comments

    If you are here because the discription doesn't match the results, you gotta consider that a tower can be reduced directly to 1. example:

    2 towers of height 7

    p1: 7 -> 1 (x=1 y=6 -> x divides y)

    p2: 7 -> 1 (x=1 y=6 -> x divides y)

    p1 loses

    p2 wins, therefore returns p2

    the description says that y should divide x but in reality x should divide y

  • + 0 comments

    Please fix that description

  • + 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