codechef prolem : Wordle Difficulty Rating:804

 

Problem

Chef invented a modified wordle.

There is a hidden word  and a guess word , both of length 5.

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 G.
  • If the guess at the â„Ž index is wrong, the â„Ž character of  is B.

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 BgBgBBGBGBbgbGB and bgbgb will all be treated as identical).

Constraints

  • 11000
  • ==5
  • , contain uppercase english alphabets only.

Sample 1:

Input
Output
3
ABCDE
EDCBA
ROUND
RINGS
START
STUNT
BBGBB
GBBBB
GGBBG

Explanation:

Test Case 1: Given string =ABCDE and =EDCBA. The string  is:

  • Comparing the first indices, AE, thus, [1]=B.
  • Comparing the second indices, BD, thus, [2]=B.
  • Comparing the third indices, C=C, thus, [3]=G.
  • Comparing the fourth indices, DB, thus, [4]=B.
  • Comparing the fifth indices, EA, thus, [5]=B.
    Thus, =BBGBB.

Test Case 2: Given string =ROUND and =RINGS. The string  is:

  • Comparing the first indices, R=R, thus, [1]=G.
  • Comparing the second indices, OI, thus, [2]=B.
  • Comparing the third indices, UN, thus, [3]=B.
  • Comparing the fourth indices, NG, thus, [4]=B.
  • Comparing the fifth indices, DS, thus, [5]=B.
    Thus, =GBBBB.
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

Popular posts from this blog

Compress PDF using python step by step

Empty recycle bin using python step by step

Convert PDF Files to PPT Files in Python.

Contact Form

Name

Email *

Message *