In Nim there are several heaps of stones, and a move removes any positive number of stones from one heap. The player who cannot move loses. Write nimMove(heaps). If the player to move is in a losing position, return null. Otherwise return [index, count]: remove count stones from the heap at index, so that the opponent is left in a losing position.
nimMove([1, 2, 3]) is null (1 ^ 2 ^ 3 = 0)nimMove([3, 4, 5]) may return [0, 2], leaving [1, 4, 5]- Any correct winning move is accepted; the tests check the result, not one specific answer