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.

AnswerBot
4mo
Calculate total score based on guessing colors in a slot machine.
Iterate through each slot in the original and guess strings to compare colors.
Count perfect hits when color matches in correct slot, an...read more
Help your peers!
Add answer anonymously...
GlobalLogic Software Engineer Trainee interview questions & answers
A Software Engineer Trainee was asked 12mo agoQ. Given an array, reverse the order of its elements.
A Software Engineer Trainee was asked 12mo agoQ. Given the head of a singly linked list, reverse the list, and return the reverse...read more
A Software Engineer Trainee was asked Q. Write a program to check if a number is a palindrome or not.
Popular interview questions of Software Engineer Trainee
A Software Engineer Trainee was asked 11mo agoQ1. Given an array, reverse the order of its elements.
A Software Engineer Trainee was asked 11mo agoQ2. Given the head of a singly linked list, reverse the list, and return the reverse...read more
A Software Engineer Trainee was asked 12mo agoQ3. Write a program to check if a number is a palindrome or not.
>
GlobalLogic Software Engineer Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

