codechef prolem : Wordle Difficulty Rating:804
Problem
Chef invented a modified wordle.
There is a hidden word and a guess word , both of length .
Chef defines a string to determine the correctness of the guess word. For the index:
- If the guess at the index is correct, the character of is .
- If the guess at the index is wrong, the character of is .
Given the hidden word and guess , determine string .
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- Each test case contains of two lines of input.
- First line contains the string - the hidden word.
- Second line contains the string - the guess word.
Output Format
For each test case, print the value of string .
You may print each character of the string in uppercase or lowercase (for example, the strings , , and will all be treated as identical).
Constraints
- contain uppercase english alphabets only.
Sample 1:
Input
Output
3 ABCDE EDCBA ROUND RINGS START STUNT
BBGBB GBBBB GGBBG
Explanation:
Test Case : Given string and . The string is:
- Comparing the first indices, , thus, .
- Comparing the second indices, , thus, .
- Comparing the third indices, , thus, .
- Comparing the fourth indices, , thus, .
- Comparing the fifth indices, , thus, .
Thus, .
Test Case : Given string and . The string is:
- Comparing the first indices, , thus, .
- Comparing the second indices, , thus, .
- Comparing the third indices, , thus, .
- Comparing the fourth indices, , thus, .
- Comparing the fifth indices, , thus, .
Thus, .
Solution:
def determine_M(S, T):
M = ""
for i in range(len(S)):
if S[i] == T[i]:
M += "G"
else:
M += "B"
return M
if __name__ == "__main__":
T = int(input())
for _ in range(T):
S = input().strip()
T = input().strip()
M = determine_M(S, T)
print(M)
Comments
Post a Comment