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.
Now think carefully such a way that , if we reduce a number X to its divisor Y . Then It eliminates some of its prime-factors .It can be turned into our standard nim game where prime factors of the number are considered to be number of stones of that particular pile. So every time when we made it equal to its divisor which in turn eliminate one or more stones from that pile . Now ,one question .
Why were the number of divisors not be evaluated to stones number of this pile ? So , think about 6,9,10 ( All have two prime factors which means state of two stones ,these three states should be treated as same ) there are same number of possible ways to divide it till 1(you can check with your hand) . So number of prime factor can be treated as number of stones of that pile .When all prime numbers will be eliminated then the state of 1 is grandy(1)=0 which in turn makes sense to us that grandy (0)=0 i.e. there is no stones (loosing state) of pile of stone .
I think the concept is little-bit clear now assuming you know well about grandy value .
6
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 →
A number can be expressed as in the form of p1 * p2 * ............where p1 ,p2... etc. are prime factors of that number .
Think about a real number 90 . It can be expressed in the form of -> 3 x 2 x 5 x 3 .
Think this like a pile of stones.
This number can be made to below numbers by one valid move according to question ..................
Now think carefully such a way that , if we reduce a number X to its divisor Y . Then It eliminates some of its prime-factors .It can be turned into our standard nim game where prime factors of the number are considered to be number of stones of that particular pile. So every time when we made it equal to its divisor which in turn eliminate one or more stones from that pile . Now ,one question .
Why were the number of divisors not be evaluated to stones number of this pile ? So , think about 6,9,10 ( All have two prime factors which means state of two stones ,these three states should be treated as same ) there are same number of possible ways to divide it till 1(you can check with your hand) . So number of prime factor can be treated as number of stones of that pile .When all prime numbers will be eliminated then the state of 1 is grandy(1)=0 which in turn makes sense to us that grandy (0)=0 i.e. there is no stones (loosing state) of pile of stone .
I think the concept is little-bit clear now assuming you know well about grandy value .
6