Bowling
Bowling is a game where, essentially, each player gets 10 turns to:
Take 2 attempts at knocking down 10 pins arranged in a triangle.
- between turns the pins are reset
- from the 1st to the 2nd attempt the pins are left as-is
The arrangement of the pins resembles the following scheme, with the pins numbered 0-9
:
6 7 8 9
3 4 5
1 2
0
(Some rules and scoring mechanics omitted.)
Split spare
In bowling, a spare is when the player manages to knock down the pins that were left standing after a first attempt. A spare is said to be a split spare1 if the pins that were left standing are not adjacent.
E.g. if the pins are laid out as such:
. . 8 9
. . .
. 2
.
Then a player who manages to knock down all these 3 pins would score a split spare, given that the pin 2
is not adjacent to the 8, 9
group.
(1 for the purposes of this challenge, a split spare is defined taking into account only the adjacency of the pins left standing, even though Wikipedia's link states that for a split spare to take place, the pin 0 must have been knocked down already)
Your task
Given the numbers of the pins left standing, output a Truthy value if such an arrangement would give a split spare and Falsy otherwise.
Input
The list of all pins left standing (at least 2), in any reasonable format. Pin numbering may be 0- or 1-indexed provided it follows the numbering direction shown above. Sensible input formats include:
- a list of integers, like
[2, 8, 9]
- a string of integers, like
"289"
- separate arguments to a function
- an integer whose bits correspond to the pints left standing and whose least significant bit corresponds to pin
0
, e.g.0b1100000100
for pins 2, 8 and 9.
You may assume input is sorted, if that helps you in any way.
Output
A single consistent value for Falsy test cases and anything else for Truthy test cases.
Test cases
Truthy
[0, 9]
[2, 8, 9]
[1, 5, 8]
[3, 5]
[3, 8]
[3, 9]
[6, 8]
[6, 9]
[3, 5, 8, 9]
[5, 6]
[0, 1, 5, 6, 7, 9]
[1, 2, 8, 9]
Falsy
[1, 2]
[7, 8, 9]
[1, 2, 5]
[2, 4]
[0, 1, 3, 6]
[2, 5, 9]
[6, 7]
[4, 7]
[4, 8]
[1, 4, 5, 7]
Bonus imaginary internet points
Bonus imaginary internet points if your algorithm works for any triangle number of pins, instead of just 10.
So far, only Grimmy's 05AB1E answer qualifies for the bonus internet points!
Standard loopholes are forbidden by default.
This is code-golf so shortest solution wins! If you enjoy the challenge, consider upvoting it... And happy golfing!
[1, 2, 8, 9]
is a split spare and for the challenge, for a spare to be a split spare we only care about adjacency. We don't care about the headpin. \$\endgroup\$code-bowling
contest somehow! \$\endgroup\$