GrundyNumber GameTheory 3

According to the question,
shouldnt grundy number of 9 be 0 as only reachable state is 3 piles of size 3 and grundy of 3 is 1 as 3 is prime
so grundy(9) = MEX(grundy(3)) = 0??

@shameek.agarwal
Yeah you’re right

So what is exactly you query here ?

@Aarnav-Jindal-1059677350830863 how is 1 reachable
question states 1**<B<**A

@shameek.agarwal
Right
Thanks for pointing it out
So what exactly is your query here ?

actually i cannot understand why grundy for primes will be 1…no rachable states from prime as only divisors 1 and number itself which arent allowed…
so mex(PHI) = 0???

please can u help me with my code @Aarnav-Jindal-1059677350830863 bhaiya??
thankss…mycode link

@shameek.agarwal
Since you’ve been given mex or prime is 1 in the question then there is no logic in challenging the assumption given in the question and it is further advisable not to do that as well
For the solution I request you to see this once


Your implementation is slightly incorrect but most importantly inefficient. You need to precalculate primes using sieve

1 Like

@Aarnav-Jindal-1059677350830863 thanks!!!
my code here works now
i think question should be changed a little tho…that piles of size 1 is not allowed(which is obvious as that means the same pile again) BUT BREAKING N INTO N PILES OF 1 IS ALLOWED

@shameek.agarwal
Sure buddy
I’ll forward your suggestion to the team
If your doubt is resolved please close it.