MathDB
Not your usual subtraction game

Source: Indonesian National Science Olympiad 2018, Mathematics P7

July 6, 2018
combinatorics

Problem Statement

Suppose there are three empty buckets and n3n \ge 3 marbles. Ani and Budi play a game. For the first turn, Ani distributes all the marbles into the buckets so that each bucket has at least one marble. Then Budi and Ani alternate turns, starting with Budi. On a turn, the current player may choose a bucket and take 1, 2, or 3 marbles from it. The player that takes the last marble wins. Find all nn such that Ani has a winning strategy, including what Ani's first move (distributing the marbles) should be for these nn.