This is a solution I prepared for the problem --> Eidi Gift.
What’s wrong with this code?? I couldn’t find any test cases not working successfully !!!
Please help !
def eidi(l):
if len(set(l[:3])) == len(set(l[3:])):
F = l[:3]
S = l[3:]
for i in range(2):
if F.index(min(F)) == S.index(min(S)):
F.pop(F.index(min(F)))
S.pop(S.index(min(S)))
continue
else:
return "NOT FAIR"
return "FAIR"
else:
return "NOT FAIR"
check = list()
for i in range(int(input())):
l = list(map(int, input().split()))
check.append(eidi(l))
print(*check, sep="\n")
Here’s my solution in python, why do you guys use so many ifs?
for _ in range(int(input())):
info = list(map(int, input().split()))
ages = info[:3]
money = info[3:]
final = sorted(list(zip(ages,money)))
final.sort(reverse=True)
flag = True
gp = final[0]
for i in range(3):
if final[i][0] < gp[0] and final[i][1] < gp[1]: gp = final[i]
elif final[i][0] == gp[0] and final[i][1] == gp[1]: gp = final[i]
else: flag = False
if flag: print("FAIR")
else: print("NOT FAIR")