Contest:
Problem:
Solution:
Carefully Generate all subsets (2**12 for each number in worst case) for both x, y and count the common ones. as xor of a number with itself is zero.
Find other accepted solutions here
one possible implementation:
def printSubSequences(STR, subSTR="", st=set()):
# src: geeksforgeeks
if len(STR) == 0:
# print(subSTR[::-1], end=" ")
if subSTR:
st.add(int(subSTR[::-1]))
return
# we add adding 1st character in string
printSubSequences(STR[:-1], subSTR + STR[-1], st)
printSubSequences(STR[:-1], subSTR, st)
return
def main(STR):
st = set()
printSubSequences(STR, st=st)
# print(st)
return st
x, y = input().split() #map(int, input().split)
x, y = main(x), main(y)
print(len(x.intersection(y)))