We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def compareTriplets(a, b):
# Initialize scores for both a and b
counta, countb = 0, 0
# Compare the first element
if a[0] > b[0]:
counta += 1
elif a[0] < b[0]:
countb += 1
# Compare the second element
if a[1] > b[1]:
counta += 1
elif a[1] < b[1]:
countb += 1
# Compare the third element
if a[2] > b[2]:
counta += 1
elif a[2] < b[2]:
countb += 1
# Return the results as a tuple
return counta, countb
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compare the Triplets
You are viewing a single comment's thread. Return to all comments →
def compareTriplets(a, b): # Initialize scores for both a and b counta, countb = 0, 0