My issue
I try to figure out the problem but, couldn’t find which condition is wrong?
My code
# cook your dish here
t = int(input())
Sum1 = 0
Sum2 = 0
for i in range(t):
a1,a2,a3,b1,b2,b3 = map(int,input().split())
Sum1+=max(a1+a2,a2+a3,a1+a3)
Sum2 +=max(b1+b2,b2+b3,b1+b3)
if Sum1 == Sum2:
print("Tie")
elif Sum1 < Sum2:
print("Bob")
else:
print("Alice")
Problem Link: DICEGAME2 Problem - CodeChef
@satya_praveen
You have declared both sum1 and sum2 outside of test case loop, so they aren’t resetting their values back to zero for each individual test case and keep adding current values to past sum.
You could have avoided it by declaring them inside the for loop, or, you could have simply assigned the values to them.
You can refer to my code to get a better understanding.
# cook your dish here
for _ in range(int(input())):
a1,a2,a3,b1,b2,b3=map(int,input().split())
s1=(a1+a2+a3)-min(a1,a2,a3)
s2=(b1+b2+b3)-min(b1,b2,b3)
if(s1>s2):
print('Alice')
elif(s1==s2):
print('Tie')
else:
print('Bob')
1 Like