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.
This can be solved quite simply following this logic.
If n is even, player 2 will create pairs of towers, such that whenever player 1 moves, they make the same move on the towers pair. Since the number of towers is even, this will always result in them winning.
Alternatively, in n is odd, then player 2 only wins if the height of the tower is 1
deftowerBreakers(n,m):# Write your code herereturn2if(n%2==0orm==1)else1
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tower Breakers
You are viewing a single comment's thread. Return to all comments →
This can be solved quite simply following this logic.
If n is even, player 2 will create pairs of towers, such that whenever player 1 moves, they make the same move on the towers pair. Since the number of towers is even, this will always result in them winning.
Alternatively, in n is odd, then player 2 only wins if the height of the tower is 1