Algorithm
problem Link : https://www.codechef.com/problems/WORDLE
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:
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, .
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int t,i;
char a[5],b[5];
scanf("%d",&t);
while(t--)
{
scanf("%s %s",a,b);
for(i=0;i < 5;i++)
{
if(a[i]==b[i]) printf("G");
else printf("B");
}
printf("\n");
}
}
Copy The Code &
Try With Live Editor
Input
ABCDE
EDCBA
ROUND
RINGS
START
Output
GBBBB
GGBBG
Demonstration
CodeChef solution WORDLE - Wordle Codechef solution in C,C++