Compare the Triplets

Sort by

recency

|

4277 Discussions

|

  • + 0 comments

    JAVA solution:

    class Result {
        public static List<Integer> compareTriplets(List<Integer> a, List<Integer> b) {
            int aa=0,bb=0;
            for(int i=0;i<a.size();i++)
            {
                if(a.get(i)>b.get(i)) aa++;
                else if(a.get(i)<b.get(i)) bb++; 
            }
            return Arrays.asList(aa,bb);
        }
    }
    
  • + 0 comments

    Here is my c++ solution, you can watch the explanation here: https://youtu.be/aI9vQg2gO0Q

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main() {
        int a1, a2, a3, alicePoint = 0, b1, b2, b3, bobPoint = 0;
        cin >> a1 >> a2 >> a3;
        cin >> b1 >> b2 >> b3;
        alicePoint = ((a1 > b1? 1:0)) + ((a2 > b2? 1:0)) + ((a3 > b3? 1:0));
        bobPoint = ((a1 < b1? 1:0)) + ((a2 < b2? 1:0)) + ((a3 < b3? 1:0));
        cout << alicePoint << " " << bobPoint ;
        return 0;
    }
    
  • + 0 comments

    I hope that my solution can help you:

    def compareTriplets(a,b):
        alicePoints = 0 # a
        bobPoints = 0   # b
        comparisonPoints = []
    
        for i in a:
            for j in b:
                # If each element of the list a and b, are greater than 1 and less than 100
                if(1 <= i <= 100) & (1 <= j <= 100):
    						# We proceed to compare the points
    						# If the index of the list a is equal to the index of the list b
                    if (a.index(i) == b.index(j)):
                        if (i > j):
                            alicePoints += 1
                        if (i < j):
                            bobPoints += 1
    
        comparisonPoints.append(alicePoints)
        comparisonPoints.append(bobPoints)
    
        return comparisonPoints
    
  • + 0 comments

    If you're looking to compare the triplets, it's always fun to see how each one stands out in its own way! Whether it's their features, personalities, or preferences, there's always something unique about each. Speaking of standing out, if you're in the market for a reliable car, check out B and G Auto Sales – they’ve got some great options to suit your needs! https://gobgautos.com/

  • + 0 comments

    import java.util.Scanner;

    public class CompareTriplets {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
    
        // Read Alice's scores
        int a0 = scanner.nextInt();
        int a1 = scanner.nextInt();
        int a2 = scanner.nextInt();
    
        // Read Bob's scores
        int b0 = scanner.nextInt();
        int b1 = scanner.nextInt();
        int b2 = scanner.nextInt();
    
        scanner.close();
    
        int aliceScore = 0;
        int bobScore = 0;
    
        // Compare scores and update scores
        if (a0 > b0) {
            aliceScore++;
        } else if (a0 < b0) {
            bobScore++;
        }
    
        if (a1 > b1) {
            aliceScore++;
        } else if (a1 < b1) {
            bobScore++;
        }
    
        if (a2 > b2) {
            aliceScore++;
        } else if (a2 < b2) {
            bobScore++;
        }
    
        System.out.println(aliceScore + " " + bobScore);
    }
    

    }