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.
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;
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 →
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; }