From b0ebb809fdf7d961a786ed12d089f90105d916ed Mon Sep 17 00:00:00 2001 From: Megha Garg <43913641+miss-jain-16@users.noreply.github.com> Date: Mon, 25 Oct 2021 17:15:07 +0530 Subject: [PATCH] Update compare-the-triplets.py rewrite the function --- algorithms/compare-the-triplets.py | 36 +++++++++++++----------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/algorithms/compare-the-triplets.py b/algorithms/compare-the-triplets.py index c54bf9f..8087599 100644 --- a/algorithms/compare-the-triplets.py +++ b/algorithms/compare-the-triplets.py @@ -2,27 +2,21 @@ import sys -def solve(a0, a1, a2, b0, b1, b2): - alice = bob = 0 - if a0 > b0: - alice += 1 - elif a0 < b0: - bob += 1 - if a1 > b1: - alice += 1 - elif a1 < b1: - bob += 1 - if a2 > b2: - alice += 1 - elif a2 < b2: - bob += 1 - return alice, bob +def compare triplets(a,b): + x=y= 0 + nas =[] + for i in range(0,len(a)): + if a[i]>b[i]: + x=x+1 + elif b[i]>a[i]: + y=y+1 + else: + continue + nas.append(x) + nas.append(y) + return nas + + -a0, a1, a2 = input().strip().split(' ') -a0, a1, a2 = [int(a0), int(a1), int(a2)] -b0, b1, b2 = input().strip().split(' ') -b0, b1, b2 = [int(b0), int(b1), int(b2)] -result = solve(a0, a1, a2, b0, b1, b2) -print (" ".join(map(str, result)))