19
1
This challenge is from a game called Keep Talking And Nobody Explodes.
Memory is a fragile thing but so is everything else when a bomb goes off, so pay attention! – from the manual
The Objective
A number from 1–4 is given as the "display", along with scrambled numbers 1–4 as the "buttons."
The output must be the label of the correct "button." Repeat this process 5 times.
The Format
The input format must be:
<display #> <buttons #>
Repeated 5 times. As long as the numbers are distinguishable and the <display #>
is dedicated separately, the input format and type don't matter. For any input that doesn't fit this format, the entire challenge falls in don't care situation.
The output format and type don't matter as long as the numbers are distinguishable.
Which button to press
Pressing a button means to output the label of the button.
The buttons are indexed from left to right, and are 1-indexed.
For the 1st line:
If the display is 1, press the button in the second position.
If the display is 2, press the button in the second position.
If the display is 3, press the button in the third position.
If the display is 4, press the button in the fourth position.
For the 2nd line:
If the display is 1, press the button labeled “4”.
If the display is 2, press the button in the same position as you pressed in line #1.
If the display is 3, press the button in the first position.
If the display is 4, press the button in the same position as you pressed in line #1.
For the 3rd line:
If the display is 1, press the button with the same label you pressed in line #2.
If the display is 2, press the button with the same label you pressed in line #1.
If the display is 3, press the button in the third position.
If the display is 4, press the button labeled “4”.
For the 4th line:
If the display is 1, press the button in the same position as you pressed in line #1.
If the display is 2, press the button in the first position.
If the display is 3, press the button in the same position as you pressed in line #2.
If the display is 4, press the button in the same position as you pressed in line #2.
For the last line:
If the display is 1, press the button with the same label you pressed in line #1.
If the display is 2, press the button with the same label you pressed in line #2.
If the display is 3, press the button with the same label you pressed in line #4.
If the display is 4, press the button with the same label you pressed in line #3.
An Example
Given the following input:
2 1432
4 3214
2 4213
1 4231
1 3214
For the 1st line, press the button in the second position, so output 4
.
For the 2nd line, press the button in the same position as you pressed in line #1, so output 2
.
For the 3rd line, press the button with the same label you pressed in line #1, so output 4
.
For the 4th line, press the button in the same position as you pressed in line #1, so output 2
.
For the last line, press the button with the same label you pressed in line #1, so output 4
.
So the entire output is 42424
, in any format and type.
1May the input be taken in more convenient formats such as
[[2, [1,4,3,2]], [4, [3,2,1,4]], ... ]
? May the buttons be 0-indexed? – Arnauld – 2019-12-14T00:39:25.373@Arnauld Sorry, the input is meant to be a string. ("string" tag is added.) By "1-indexed" I mean it is 1-indexed in the description. If you are going to store them in an array, it doesn't matter whether it's 0-indexed or 1-indexed. – Dannyu NDos – 2019-12-14T00:45:57.257
9
Just as a friendly reminder: unless the very purpose of the challenge is to parse something or to deliver an exact output, cumbersome I/O formats are just an annoyance.
– Arnauld – 2019-12-14T01:04:44.497@Arnauld Fine.. – Dannyu NDos – 2019-12-14T01:12:41.363