from collections import defaultdict graph=defaultdict(list) v,e=map(int,input().split()) for i in range(e): u,v=map(str,input().split()) graph[u].append(v) graph[v].append(u) for i in graph: print(i,"->",graph[i]) Input: 7 9 A B A C A F C E C F C D D E D G G F Output: F -> ['A', 'C', 'G'] C -> ['A', 'E', 'F', 'D'] G -> ['D', 'F'] D -> ['C', 'E', 'G'] A -> ['B', 'C', 'F'] E -> ['C', 'D'] B -> ['A']
Find the XOR of two numbers and print it.
Hint: Input the numbers as strings.
Input Format
First-line contains the first number X and the second line
contains second number Y.
The numbers will be given to you in binary form.
Constraints
0 <= X <= 2^1000
0 <= Y <= 2^1000
Output Format
Output one number in binary format, the XOR of two
numbers.
Sample Input 0
11011
10101
Sample Output 0
01110
CODE:
a=input()
b=input()
c=""
if len(a)<=len(b):
k=len(b)-len(a)
l="0"*k
a=l+a
else:
k=len(a)-len(b)
l="0"*k
b=l+b
for i in range(len(a)):
c+=str(int(a[i])^int(b[i]))
Comments
Post a Comment