Created
August 3, 2017 02:13
-
-
Save furby-tm/a3f72f1815827aca3ff637e253ef4500 to your computer and use it in GitHub Desktop.
HackerRank Solution for Triplets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int[] alicesTriplet = new int[3]; | |
int[] bobsTriplet = new int[3]; | |
int alicesTotal = 0; | |
int bobsTotal = 0; | |
for (int i = 0; i < 3; i++) { | |
alicesTriplet[i] = in.nextInt(); | |
} | |
for (int i = 0; i < 3; i++) { | |
bobsTriplet[i] = in.nextInt(); | |
} | |
for (int i = 0; i < 3; i++) { | |
if (alicesTriplet[i] == bobsTriplet[i]) { | |
alicesTotal += 0; | |
bobsTotal += 0; | |
} else if (alicesTriplet[i] > bobsTriplet[i]) { | |
alicesTotal += 1; | |
} else { | |
bobsTotal += 1; | |
} | |
} | |
System.out.print(alicesTotal + " " + bobsTotal); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment