Say we are given n piles of stones. Sizes are $s_{1}, s_{2}, .. , s_{n}$, they can be any positive integer numbers. The game is played by two players, they alternate their moves. The allowed moves are: 1. Take exactly 1 stone from 1 pile. 2. Take all stones from 1 pile.
Wins the player who mades the last move. Both play optimally.
Is it possible to find the winner for some state? I was thinking about Grundy numbers, but stuck with definitions and do not know can it be applied here.
If both the number of piles with an odd number of sticks and the number of non-empty piles with an even number of sticks are even, the first player loses. Otherwise the first player wins.
Proof:
Let's label the game positions with (parity of number of odd-stick piles, parity of number of even-stick piles). With that,the condition above can be reformulated as: If the position is (even,even), the first player loses, otherwise the first player wins.
Also, since for a pile with only one stick, taking one stick and taking the whole pile is obviously the same move, I'll stick to the convention that "taking one stick" does not include "taking the last stick of a pile".
If at your turn no non-empty piles are left, you've obviously lost. That obviously is an (even,even) state.
If you are presented with another (even,even) state, you obviously have only the following four possibilities (not all of them may be available):
You remove a single stick from some pile, turning that pile's parity, and thus resulting in an (odd,odd) state. Then your opponent can do the same (note that there is at least one pile with more than one stick, as there is at least one non-empty even-sticks pile, which has at least two sticks), and thus again prevent you with a (even,even) state.
You remove a complete even-sticks pile, resulting in an (even,odd) state. Again, your opponent can do the same, presenting you an (even,even) state again.
Finally, you may remove a complete odd-stick pile, resulting in an (odd,even) state. Also in this case, your opponent can do the same, presenting you an (even,even) state again.
So if you get an (even,even) state, your opponent can make sure that whatever you do, you will get an (even,even) state again. Since every move reduces the number of sticks, you'll eventually be presented with thew (even,even) state of no heaps left, that is, you will lose.
Now if you are not presented an (even,even) state, you will be presented one of the following:
(even,odd): Remove one of the even-stick piles.
(odd,even): Remove one of the odd-stick piles.
(odd, odd): Remove a single stick from a pile with more than one pile.
In all cases the opponent will then get an (even,even) state, and therefore lose, so you win.