This challenge is from a game, Keep Talking And Nobody Explodes.
This is like one of those toys you played with as a kid where you have to match the pattern that appears, except this one is a knockoff that was probably purchased at a dollar store. – From the manual
Objective
The Simon Says module consists of 4 colored buttons: Red, Blue, Green, and Yellow. Given a sequence of button flashes and a sequence of button presses, decide whether it would disarm the module.
In the original game, the module consists of multiple stages, but in this challenge, only one stage will be considered.
How To Disarm
The buttons will flash in a sequence. These buttons shall be mapped accordingly to the chart below, and shall be pressed.
You may press the wrong button in cost of a strike. Then the mapping will change. Only up to 2 strikes are tolerable because a 3rd strike will detonate the bomb.
You must not press buttons anymore after the module is disarmed.
The chart:
Strikes\Flash Red Blue Green Yellow
0 Blue Red Yellow Green
1 Yellow Green Blue Red
2 Green Red Yellow Blue
(This chart is for a bomb whose serial number has a vowel. It is assumed for the purpose of this code-golf challange.)
I/O format
The input shall be two strings consisting of R
, B
, G
, and Y
, indicating the colors. Case sensitive.
Though in the game, a stage consists of up to 5 flashes, in this challenge, there may be an arbitrary nonzero number of flashes.
An input not fitting to this format falls in don't care situation.
The output format is flexible.
Examples
Let's say the button flash sequence is GRYBB
. The followings are examples of button press sequences:
Truthy
YBGRR
RBYRGG
(in cost of 1 strike)YBGRBG
(in cost of 1 strike)YBGBGRR
(in cost of 2 strikes)
Falsy
YBG
(The module isn't disarmed yet)RRR
(The 3rd strike detonated the bomb)YBGRRB
(You cannot press buttons anymore after the module is disarmed)RRRY
(You cannot press buttons after the bomb detonates)