Solution:
Let us first assume that we start from a situation in which there is at least one token present on the table, otherwise the game cannot even begin.
Let C0,C1,C2,… be the combinations of piles present at the start of the game, after the first move, after the second move, and so on. For each combination Ci let ri be the number of piles that have a number of tokens a1,a2,…,ari greater than 1 and si the number of piles that have one token. Let then mi=(a1−1)+⋯+(ari−1). We show that Barbara has a winning strategy if m0 and s0 are both even and that Alberto has a winning strategy in all other cases. The winning strategy is to leave the opponent, at each move, a combination Ci such that mi and si are both even.
Indeed, observe that if a player is facing a combination in which mi and si are both even, every move they make must lead to a combination in which at least one of mi+1 and si+1 is odd. Conversely, suppose a player is facing a combination in which mi and si are not both even:
- if mi is even and si is odd, they can remove a pile with 1 token;
- if mi is odd and si is even, they can remove a token from a pile with at least 3 tokens (if one exists), or split a pile with 2 tokens into two piles with one token;
- if mi and si are both odd, they can split a pile with a≥3 tokens (if one exists) into two piles with a−1 and 1 token, or they can remove a token from a pile containing 2.
In all cases, the player manages to produce again a combination in which mi+1 and si+1 are both even.
Since during the game the number of tokens present on the table can be left unchanged at most m0 times, the game certainly ends, and clearly the victory will go to whoever manages to propose the combination Cn in which mn=sn=0, both even.