Learn / Library / Brainteasers
Bottles in a row
bottles stand in a row at positions to . players alternate; a move knocks down either standing bottle or standing bottles at neighbouring positions. Bottles never move, so a fallen bottle leaves a gap that splits the row. The player who knocks down the last bottle wins. You move first and both players play optimally. A first move is the set of bottles it knocks down. How many different first moves guarantee you a win?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
A mirror reply works after a central move, but other first moves may win too: give each segment of the row a value and combine the values.
Solution
- Knocking down the bottle at position leaves rows of , and copying every opponent move on the other side then wins, so a winning move exists.
- To count all winning moves, give each row of bottles a value : the smallest non-negative whole number not among the XORs of the values of the pieces its moves leave.
- This gives to as , , , , , , , , , , , , , , , and a first move wins exactly when the XOR of the values of the rows it leaves is .
- No move that removes bottles works, but removing bottle wins when it leaves rows of and , and , or and , in either order.
- These are the bottles at positions , , , and , so the answer is .
Answer: