# A game with 330 pebbles

Anastasia and Barnabas play a game that starts with $330$ pebbles in a bowl. The game consists of two phases. The first phase looks as follows:

• First Anastasia announces an integer $A$ with $2\le A\le9$.
• Then Barnabas announces an integer $B$ with $2\le B\le9$ and $B\ne A$.

The second phase looks as follows:

• The two players alternately take pebbles out of the bowl. Anastasia makes the first move.
• In every move, Anastasia may either take $1$ pebble or $A$ pebbles.
• In every move, Barnabas may either take $1$ pebble or $B$ pebbles.
• The player who takes the last pebble wins the game.

Question: Which player is going to win this game? (As usual, we assume that Anastasia and Barnabas both use optimal strategies.)

• What happens if A = 5 and at one point there are 4 pebbles on the table and it's A's turn? It is considered a win? – Marius Apr 6 '16 at 7:42
• @Marius: Then A will take 1 pebble, according to the rules. – Gamow Apr 6 '16 at 7:42
• No Alice and Bob? :o – Tim Couwelier Apr 6 '16 at 8:06
• @Devsman, Barnabas chooses after Anastasia has chosen, therefore Barnabas has more information, so he might be able to use the information about the moves Anastasia can make to choose a better strategy then Anastasia. – Kasper van den Berg Apr 6 '16 at 14:43
• @Devsman Let's play Rock Paper Scissors : you can start and apply your better strategy, I will choose after you ;) – Fabich Apr 6 '16 at 14:46

Anastasia wins

Because

Anastasia is the first to choose the integer and she chooses $A = 2$.

Anastasia should first reach a status where there's a number of pebbles left less than $B$.
To achieve this, on every Anastasia's turn we can say that there are

$B + n$ pebbles left

As long as $n > 2$, she can play whatever number. When $n \leq 2$ Anastasia must play the correct number: if $n = 2$ she plays $1$, else if $n = 1$ she plays $2$.
The status after this move is either $B + 1$ or $B - 1$ and it's Barnabas' turn. He cannot win at this turn (because $B \geq 3$) and after his turn we have less than $B$ pebbles left.
Anastasia should now just make sure that after her turn there's an even number of pebbles left, so that Barnabas' can't win. On the last turn there's just 1 pebble left and it's Anastasia's turn.

• I had the same idea but you beat me to it :) – Tim Couwelier Apr 6 '16 at 8:18