We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Tower Breakers
  2. Discussions

Tower Breakers

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 110 Discussions, By:

votes

Please Login in order to post a comment

  • yuangao212
    8 months ago+ 4 comments

    More of an English challenge than a coding challenge.

    226|
    Permalink
    View more Comments..
  • narindhatwalia21
    8 months ago+ 19 comments

    Even though I got the answer and the underlying logic, I still think this is actually a very tough problem. I say so because of the following reasons:

    1. You have to first understand the complicated game and its rules properly (slightly challenging)

    2. You then have to find the correct way to win this game from the perspective of each player (extremely challenging)

    So basically, there are two cases here. Both cases rely heavily on the idea that an even number of towers (say 2n) can be thought of as a collection of n pairs of towers.

    CASE 1) If there are an even number of towers Player 1 will go first, and Player 2 will basically copy player 1. Whatever player 1 does to a tower, player 2 will do the exact same thing to the other tower belonging to the same pair. In this case Player 2 will always win.

    CASE 2) If there are an odd number of towers Player 1 will go first, and simply destroy any single tower by setting it equal to 1. Now we again have the same situation from CASE 1 but this time the roles of both players have been reversed. In this case Player 1 will always win.

    Finally, there is also the trivial case where n does not matter because m = 1. In this case Player 2 will obviously always win.

    185|
    Permalink
    View more Comments..
  • graphei_com
    9 months ago+ 4 comments

    This difficulty is suposed to be EASY.

    Typo: "Player 1 removes 2 pieces leaving 1. Towers are 1 and 2 units tall."

    Should read: "Player 1 removes 2 pieces leaving 1. Towers are 1 and 3 units tall."

    This made me crazy, I kept tyring to figure out what I was missing.

    96|
    Permalink
    View more Comments..
  • erika_n_mack1
    8 months ago+ 2 comments

    How is taking 5 and leaving 1 evenly divisible? Is the problem saying your options are to reduce the tower by making an equally divsible group OR reducing the tower down to 1?

    46|
    Permalink
  • natlosh
    9 months ago+ 1 comment

    In the example given can't player 1 also take four blocks leaving two? As 6%2 = 0?

    37|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature