Compare the Triplets

  • + 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);
    }
    

    }