Gray to Binary and Binary to Gray
Submissions: 242   Accuracy:

49.59%

  Difficulty: Basic   Marks: 1

Given to strings B and G. String B represents a binary code and string G represents a Gray Code. You need to write a program which converts binary code to gray code and vice versa.

Input:
First line of input contains a single integer T which denotes the number of test cases. Then T test cases follows. First line of each test case contains a string B. Second line of each test case contains a string G.

Output:
For each test case, in the first line convert the binary code in string B to gray code and print. In the second line convert the gray code in string G to binary code and print.

Constraints:
1<=T<=100
1<=length(B)<=105
1<=length(G)<=105

Example:
Input:
2
0011
01101
01001
01101
Output:
0010
01001
01101
01001

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harsh Agarwal
Author: harsh.agarwal0


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.