• + 2 comments

    The way I see it, the second test case is wrong. 1 tower of 7 pieces. If players do the optimal play, the game would go like this:

    • Player 1 takes 1, tower size = 6;
    • Player 2 takes 3, tower size = 3;
    • Player 1 takes 1, tower size = 2;
    • Player 2 takes 1, tower size = 1; Player 1 has no move, Player 2 wins return 2

    Same with the second one. 3 tower of 7 pieces. Player 2 forces P1 to take the first piece from each tower and Player 2 will win.