Link- CodeChef: Practical coding for everyone
I realise that by seeing others solutions that the answer will be Gaitonde if the XOR of all numbers is non-zero or Isa otherwise(if zero), but can anybody explain the logic behind it?
It’s the game of Nim in (a bit of a) disguise.
The reasons why the xor trick works is due to the Sprague Grundy Theorem.
Hackerrank have a Game Theory section with lots of nice practice problems
So quick! Did you take part in the contest? Anyway I was solving problems after the contest was over and I found the 5th problem easier then this one. I couldn’t crack this.
No, that contest was too short for me The Hackerrank Game Theory section is full of Nim-style games, so I was primed to spot it quite quickly
This question is really a “you have to know it (or at least Google it)” - the Sprague-Grundy Theorem is not something people are likely to come up with in a 2 hour contest, and the results of the theorem are not at all intuitive.
@anon62928982 Yeah, this is the correct explaination.
I am the setter for the question, the editorial is Coming Soon !
How to solve the question Sartaj Drinks Gotchi?
Thanks for the links
Because I checked, Gaurav Sen has nice videos on Game Theory and Grundy Numbers. You may want to check that.
Thanks to you too