On the Subject of Wire Sequence
This challenge is from a game, Keep Talking And Nobody Explodes.
It's hard to say how this mechanism works. The engineering is pretty impressive, but there must have been an easier way to manage nine wires. — from the manual
Input
Exactly 9 "wires", each which is labeled 'A', 'B', or 'C', and is colored red, blue, or black.
Input format and type doesn't matter, as long as they uniquely identify the wires. In particular, the alphabets can be encoded arbitrarily, so can the colors.
Objective and Output
Output the indices of the wires that needs to be cut. The output format and type doesn't matter either, as long as they uniquely identify the wires to be cut.
Which wire to cut?
For each color, and then for each number of cumulative occurences of that color, the alphabet determines whether the wire must be cut.
$$ \begin{array}{c|ccc} & \text{Red} & \text{Blue} & \text{Black} \\ \hline \text{1st} & \text{C} & \text{B} & \text{A, B, or C} \\ \text{2nd} & \text{B} & \text{A or C} & \text{A or C} \\ \text{3rd} & \text{A} & \text{B} & \text{B} \\ \text{4th} & \text{A or C} & \text{A} & \text{A or C} \\ \text{5th} & \text{B} & \text{B} & \text{B} \\ \text{6th} & \text{A or C} & \text{B or C} & \text{B or C} \\ \text{7th} & \text{A, B, or C} & \text{C} & \text{A or B} \\ \text{8th} & \text{A or B} & \text{A or C} & \text{C} \\ \text{9th} & \text{B} & \text{A} & \text{C} \end{array} $$
Example
Assuming the wires are 1-indexed, and given the following input:
Blue C
Blue C
Black C
Black B
Black A
Red C
Blue C
Black A
Black A
The 1st wire is the 1st blue wire, so leave it.
The 2nd wire is the 2nd blue wire, so cut it.
The 3rd wire is the 1st black wire, so cut it.
The 4th wire is the 2nd black wire, so leave it.
The 5th wire is the 3rd black wire, so leave it.
The 6th wire is the 1st red wire, so cut it.
The 7th wire is the 3rd blue wire, so leave it.
The 8th wire is the 4th black wire, so cut it.
The 9th wire is the 5th black wire, so leave it.
So the output is [2,3,6,8].
- 7.4k
- 1
- 28
- 92