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.
if m (tower height) is 1, then Player 1 is unable to make a move, and lose the game. Player 2 is winner.
For all other tower heights, the winner is determined by the number of towers n. Simulate 4 scenarious: with odd and even number of towers (1 and 2), with height 2, then 3, when each player makes it best (optimal) move.
Happy pythoning!
🦁
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 →
Python 3
Explanation:
m
(tower height) is 1, then Player 1 is unable to make a move, and lose the game. Player 2 is winner.n
. Simulate 4 scenarious: with odd and even number of towers (1 and 2), with height 2, then 3, when each player makes it best (optimal) move.Happy pythoning!
🦁