How to solve Game theory question ?

Hello, I have been trying to solve this problem https://www.codechef.com/problems/GTH , but I am unable to solve this.

Can anyone please tell, how to solve this problem ?

This game is equivalent to the game of nim. You have N (= 26 here, corresponding to each alphabet) piles with a certain number of stones each. (here the number of occurrences of the alphabet corresponding to that pile)

The solution to this game is dependent on the XOR of all the stone amounts, which is called the “nimsum” of a “position”.

You can find more here.

1 Like