Background
Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8)
configuration.
||| ||||| ||||||||
Let's call the two players Alice (the one who plays first) and Bob (second). At each turn, the player selects one stick anywhere on the board, and removes that stick along with the ones directly adjacent to it (left or right within the group).
For example, if Alice chooses the 3rd stick in the 5-stick group, the board becomes (3,1,1,8)
(sticks removed in the middle split the group into two):
||| |xXx| ||||||||
Then, if Bob chooses the first stick in the 8-stick group, the board becomes (3,1,1,6)
:
||| | | Xx||||||
Then if Alice chooses the 2nd stick in the 3-stick group, that group is entirely removed and the state becomes (1,1,6)
:
xXx | | ||||||
The one who eliminates all the sticks from the board wins the game.
For single-pile initial states, Alice can win in 1 turn for (1)
through (3)
, and (5)
in three turns by removing the middle. However, Alice cannot win for (4)
because any move will result in a (1)
or (2)
, where Bob can win in 1 turn.
Challenge
Given an initial configuration of Stick Bomber, determine whether Alice can win the game. Assume that both Alice and Bob play perfectly, i.e. each player always plays a winning move whenever possible.
The input is guaranteed to be a non-empty sequence of positive integers, but it is not guaranteed to be sorted. For output, you can choose to
- output truthy/falsy using your language's convention (swapping is allowed), or
- use two distinct, fixed values to represent true (affirmative) or false (negative) respectively.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
Single-group configurations
For n < 70
, Alice wins for (n)
unless n
is one of the following. This result was generated using this Python code. This sequence and its inversion (the list of n
's where Alice wins) are not yet part of the OEIS.
4, 8, 14, 20, 24, 28, 34, 38, 42, 54, 58, 62
Multi-group truthy
[2, 9] [3, 5] [3, 7] [3, 9] [7, 8]
[1, 2, 7] [1, 8, 9] [3, 8, 9] [6, 7, 9] [7, 8, 9]
[1, 3, 6, 6] [1, 4, 4, 9] [1, 5, 6, 7] [2, 5, 6, 7] [3, 4, 8, 9]
Multi-group falsy
[1, 6] [1, 7] [4, 4] [5, 5] [5, 9]
[1, 7, 8] [2, 3, 9] [3, 3, 4] [4, 5, 9] [8, 9, 9]
[1, 2, 4, 4] [1, 4, 4, 7] [2, 2, 5, 9] [2, 6, 6, 7] [3, 4, 7, 9]
[1,6]
seems unwinnable by a manual exhaustive check. \$\endgroup\$||| ||||| ||||||||
or even111 11111 11111111
? \$\endgroup\$