Compare the Triplets

Sort by

recency

|

4359 Discussions

|

  • + 0 comments

    It's a concise and effective exercise for mastering comparison-based logic in programming. Ekbet86

  • + 0 comments
        compare = [a[i] - b[i] for i in range(len(a))]
        
        sumA = sum(1 for n in compare if n > 0)
        sumB = sum(1 for n in compare if n < 0)
        
        return sumA, sumB
    
  • + 0 comments

    What should I do when an input constraint is met ? For example if one of Alice's input scores is >100, should I just not give a point to either in this case ?

  • + 0 comments

    For Python3 Platform

    def compareTriplets(a, b):
        alice = bob = 0
        
        for i in range(3):
            if(a[i] > b[i]):
                alice += 1
            elif(a[i] < b[i]):
                bob += 1
        
        return [alice, bob]
    
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    
    result = compareTriplets(a, b)
    
    print(*result)
    
  • + 0 comments

    function compareTriplets(a, b) { let [_a, _b] = [a, b]; let res = [0, 0];

    _a.map((f, i) => {
        if(f !== _b[i]) {
            const r = Math.max(f, _b[i]) === _b[i];
            res[~~r]++;
        }
    });
    
    return res;
    

    }