## HackerRank.com Challenge – Compare the Triplets

I recently completed the HackerRank.com Challenge “Compare the Triplets”. Below is the answer I submitted.

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

public class Solution {

static int[] solve(int a0, int a1, int a2, int b0, int b1, int b2){
// Complete this function

int score_a = 0;
int score_b = 0;

//verify all numbers are in the appropriate range.
if(a0 >= 1 && a0 <= 100 &&
a1 >= 1 && a1 <= 100 &&
a2 >= 1 && a2 <= 100 &&
b0 >= 1 && b0 <= 100 &&
b1 >= 1 && b1 <= 100 &&
b2 >= 1 && b2 <= 100)
{
//System.out.println("All numbers in valid range");

//tabulate score for a0/b0
if(a0 > b0)
{
score_a++;
}
else if(a0 < b0)
{
score_b++;
}

//tabulate score for a1/b1
if(a1 > b1)
{
score_a++;
}
else if(a1 < b1)
{
score_b++;
}
//tabulate score for a2/b2
if(a2 > b2)
{
score_a++;
}
else if(a2 < b2)
{
score_b++;
}

int[] number = {score_a, score_b};
return number;
}
else
{
System.out.println("The input needs to be between 1 and 100. Please correct the input and try again.");
int[] number = {0, 0};
return number;
}

}

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a0 = in.nextInt();
int a1 = in.nextInt();
int a2 = in.nextInt();
int b0 = in.nextInt();
int b1 = in.nextInt();
int b2 = in.nextInt();
int[] result = solve(a0, a1, a2, b0, b1, b2);
for (int i = 0; i < result.length; i++) {
System.out.print(result[i] + (i != result.length - 1 ? " " : ""));
}
System.out.println("");

}
}
```