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.
Create two arrays: g1 and g2.
Let g1 contains grundy numbers of piles with zero-move used, and g2 contains those without.
See the link between these two arrays.
Real spoiler!
g1[0]=0
g1[1]=mex{g1[0]}=1
g1[2]=mex{g1[0], g1[1]}=2
...
g2[0]=0
g2[1]=mex{g1[1], g2[0]}=2
g2[2]=mex{g1[2], g2[0], g2[1]}=1
...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Zero-Move Nim
You are viewing a single comment's thread. Return to all comments →
(If someone is struggling) Caution, spoiler!
Create two arrays: g1 and g2. Let g1 contains grundy numbers of piles with zero-move used, and g2 contains those without. See the link between these two arrays.
Real spoiler!
g1[0]=0
g1[1]=mex{g1[0]}=1
g1[2]=mex{g1[0], g1[1]}=2
...
g2[0]=0
g2[1]=mex{g1[1], g2[0]}=2
g2[2]=mex{g1[2], g2[0], g2[1]}=1
...