My issue
Its Not working as expected why …?
My code
# cook your dish here
t = int(input())
for i in range(t):
A,B,A1,B1,A2,B2 = input().split()
A = int()
B = int()
A1 = int()
B1 = int()
A2 = int()
B2 = int()
if A == A1 or B1:
if B == A1 or B1:
print("1")
else:
continue
elif A == A2 or B2:
if B == A2 or B2:
print("2")
else:
continue
else:
print("0")
Problem Link: PROGLANG Problem - CodeChef
@deveshrana
There seems to be a few problems with your code.
- Not taking inputs correctly: map function would have been useful to take multiple inputs present in a single line, or, they could have been taken as a list like;
a,b,c,d,e,f=map(int,input().split())
or
l=list(map(int,input().split())
- Not checking condition correctly: Your if condition will not check if A equals to B1. It will only check if A equals to A1 and will take B1 as either True, if B is non-zero, or as False, if B is zero.
The condition should have been like this;
if( (A==A1) or (A==B1) ):
You can have a look at my code for better understanding.
for _ in range(int(input())):
a,b,a1,b1,a2,b2=map(int,input().split())
if( ((a==a1)or(a==b1))and((b==b1)or(b==a1)) ):
print(1)
elif( ((a==a2)or(a==b2))and((b==b2)or(b==a2)) ):
print(2)
else:
print(0)
Thanks for the help, it works well now i also now understand where i went wrong …