Skip to content

Instantly share code, notes, and snippets.

@furby-tm
Created August 3, 2017 02:13
Show Gist options
  • Save furby-tm/a3f72f1815827aca3ff637e253ef4500 to your computer and use it in GitHub Desktop.
Save furby-tm/a3f72f1815827aca3ff637e253ef4500 to your computer and use it in GitHub Desktop.
HackerRank Solution for Triplets
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