Anecdote - 1
June 6, 20261 min read
Codechef Anecdotes
This one was pretty cool, instead of nesting 3 if else and becoming a digital mazdoor, i was like coding doesnt allow repeating yourself so many times, so i just added programing concepts and some well thought out logic to reduce manually written if else.
t = int(input())
class person:
def __init__(self, name, marks):
self.name = name
self.marks = marks
while(t):
t-=1
d = person("dragon", list(map(int, input().split(" "))))
s = person("sloth", list(map(int, input().split(" "))))
if (sum(d.marks) > sum(s.marks)):
print(d.name)
elif (sum(d.marks) < sum(s.marks)):
print(s.name)
else:
result = False
i = 0
while(i<3 and (not result)):
if d.marks[i] == s.marks[i]:
i+=1
else:
if d.marks[i] > s.marks[i]:
print(d.name)
result = True
else:
print(s.name)
result = True
if (not result):
print("Tie")
ps python is the coolest language to type in (i still love C, its just a lot more verbose) [f u js]