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.
It was my initial thought as well but that assumes P1 decides to be greedy and reduce the T1 (of 2 towers) by 5 i.e. P1 takes 2nd option of their example:
*There are 2 towers, each 6 units tall. Player 1 has a choice of two moves:
- remove 3 pieces from a tower to leave 3 as 6 modulo 3 = 0
- remove 5 pieces to leave 1 *
However if P1 reduce T1 by only 3 and P2 is greedy and reduce T2 by 5. P1 gets to reduce T1 by 2. P2 can't make a move and loses. Greed != Win :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Tower Breakers
You are viewing a single comment's thread. Return to all comments →
It was my initial thought as well but that assumes P1 decides to be greedy and reduce the T1 (of 2 towers) by 5 i.e. P1 takes 2nd option of their example: *There are 2 towers, each 6 units tall. Player 1 has a choice of two moves: - remove 3 pieces from a tower to leave 3 as 6 modulo 3 = 0 - remove 5 pieces to leave 1 *
However if P1 reduce T1 by only 3 and P2 is greedy and reduce T2 by 5. P1 gets to reduce T1 by 2. P2 can't make a move and loses. Greed != Win :)