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.
"countPrimes(n)" counts how many numbers goes into the prime factorization of n. (Not unique primes, but rather total primes. So countPrimes(8) = 3).
The goal is to turn this into a nimGame, so we can use xor. If a tower has a height of 8, that's the same as a pile with 3 stones, since there are 3 ways of dividing it lower.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tower Breakers, Revisited!
You are viewing a single comment's thread. Return to all comments →
Here's my solution (with two helper functions):
"nimGame" is just the solution from: https://www.hackerrank.com/challenges/nim-game-1
"countPrimes(n)" counts how many numbers goes into the prime factorization of n. (Not unique primes, but rather total primes. So countPrimes(8) = 3).
The goal is to turn this into a nimGame, so we can use xor. If a tower has a height of 8, that's the same as a pile with 3 stones, since there are 3 ways of dividing it lower.