Rainbow Department
Statement
Goal
As an operator in the Rainbow Department, each time a new order for a rainbow is being processed, you have to validate it.The guidelines for approved rainbows change from time to time, so in each order there is a record of the current ruleset.
The ruleset is a string with each allowed uppercase character representing a color and the order in which it has to show in the request.
All the allowed colors should be present in a rainbow request, in order.
Allowed colors in the wrong order and not allowed colors are considered illegal characters.
Only characters between A and Z are considered colors, everything else is ignored.
Example:
If the operator is waiting for an ABC ruled rainbow, and receives a BABC rainbow, the rainbow is invalid!
With 1 invalid character.
B considered a color, and it's read when we are waiting to read an A, so it's incorrect.
If he received A9BCi istead, that would be valid, because 9 and i are not colors!
Input
Line 1: A string with the allowed characters
Line 2: A string to check
Line 2: A string to check
Output
If the requested rainbow is legal: Rainbow accepted! 0
else: Rainbow denied! n
where n is the number of illegal characters in the request
else: Rainbow denied! n
where n is the number of illegal characters in the request
Constraints
0 < Length of rainbow < 100
Example
Input
RAPFJ R99pAaPF!J
Output
Rainbow accepted! 0
Game modes
Fastest, Shortest
Test cases
Test 1 Test
Input
RAPFJ
R99pAaPF!J
Output
Rainbow accepted! 0
Validator 1 Validator
Input
RATFJ
Rtj39ATF!J
Output
Rainbow accepted! 0
Test 2 Test
Input
A
23'852"?AA
Output
Rainbow denied! 1
Validator 2 Validator
Input
A
A2"931332A
Output
Rainbow denied! 1
Test 3 Test
Input
RGB
BGR
Output
Rainbow denied! 2
Validator 3 Validator
Input
BCATZ
ZTACB
Output
Rainbow denied! 4
Test 4 Test
Input
QWERTY
!Q!W!E!R!T!Y!
Output
Rainbow accepted! 0
Validator 4 Validator
Input
GHJKL
!G!H!J!K!L!
Output
Rainbow accepted! 0
Test 5 Test
Input
ABC
ABCD
Output
Rainbow denied! 1
Validator 5 Validator
Input
ABC
ABCABCAB
Output
Rainbow denied! 5
Test 6 Test
Input
FERB
FER
Output
Rainbow denied! 0
Validator 6 Validator
Input
TYZA
TYZ
Output
Rainbow denied! 0
Test 7 Test
Input
ABC
AABC
Output
Rainbow denied! 1
Validator 7 Validator
Input
ATF
AFT
Output
Rainbow denied! 1
Solution language
Solution
Stub generator input