Slot Game Problem Statement
You are given a slot machine with four slots, each containing one of the colors Red (R), Yellow (Y), Green (G), or Blue (B). You must guess the colors without prior knowledge. For each correct guess in the correct slot, you score a 'perfect hit' worth 2 points. For guessing a correct color but in the wrong slot, you score a 'pseudo-hit' worth 1 point.
Your task is to calculate the total score based on your guess against the correct slot colors.
Example:
Input:
Original String = “RGYB”
Guess String = “YGRR”
Output:
4
Explanation:
The second slot in both strings matches perfectly, resulting in a perfect hit. The guess string includes 'Y', a color from the original string but in a different slot, counting as a pseudo-hit. Similarly, two 'R' guesses partially match the single 'R' in the original, resulting in additional pseudo hits. Total points = 2 (perfect) + 1 (pseudo) + 1 (pseudo) = 4.
Constraints:
- 1 ≤ T ≤ 5
- Each string, 'original' and 'guess', has a length of 4
- Time limit: 1 second
Note:
You are not required to print anything; just implement the function to determine the score.
Be the first one to answer
Add answer anonymously...
Top GlobalLogic Software Engineer Trainee interview questions & answers
Popular interview questions of Software Engineer Trainee
Top HR questions asked in GlobalLogic Software Engineer Trainee
>
GlobalLogic Software Engineer Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app