Python Wrong Answer

Can anybody tell me why uncommented solution is giving wrong answer, but the commented one is correct? what’s the difference between them??
for _ in range(int(input())):
n,k = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
for i in a:
if i%k==0: print(‘1’, end=’’)
else: print(‘0’, end=’’)

# for test in range(int(input())):
#     d, k=map(int, input().strip().split())
#     distances=list(map(int, input().strip().split()))
#     ans=[]
#     for dist in distances:
#         if dist%k==0:
#             ans.append('1')
#         else: ans.append('0')
#     print(''.join(ans))

A simple print() statement at the end of for loop would give AC. :slight_smile:
Also, you should have tested your solution against more than 1 test case(s). It was mentioned to print every answer on a new line.

uncommented code would publish answers for all the cases in a line.
You need to break line for every test.

Consider formatting your code while posting it.

1 Like