Friday, December 16, 2016

Compare the Triplet

Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from to for three categories: problem clarity, originality, and difficulty.
We define the rating for Alice's challenge to be the triplet , and the rating for Bob's challenge to be the triplet .
Your task is to find their comparison scores by comparing with , with , and with .
  • If , then Alice is awarded point.
  • If , then Bob is awarded point.
  • If , then neither person receives a point.
Given and , can you compare the two challenges and print their respective comparison points?


Solution : 

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int alice=0;
        int bob=0;
        int a0 = in.nextInt();
        int a1 = in.nextInt();
        int a2 = in.nextInt();
        int b0 = in.nextInt();
        int b1 = in.nextInt();
        int b2 = in.nextInt();
       
        if (a0<b0){
            bob+=1;
           
        }
        if (a1<b1){
            bob+=1;
           
        }
        if (a2<b2){
            bob+=1;
          
        }
        if(a0>b0 ){
            alice+=1;
          
           
        }
        if(a1>b1 ){
            alice+=1;
           
           
        }
        if(a2>b2){
            alice+=1;
           
           
        }
        if(a0==b0){
            alice+=0;
           bob+=0;         
          
        }
        if(a1==b1){
            alice+=0;
           bob+=0;         
          
        }
        if(a2==b2){
            alice+=0;
           bob+=0;         
          
        }
        System.out.println(alice+" "+bob);
    }
}

1 comment: