I did it!!!
import java.io.*;
// 427 lines 200
public class Base {
static char suit (String tokens) { return tokens.charAt (1); }
public static char num (String tokens) { return tokens.charAt (0);}
public static void checkPair (String [] tokens)
{
for (int a = 0; a < 4; ++a)
for (int b = a+1; b < 5; ++b)
if (num (tokens [a]) == num (tokens [b]))
System.out.print (tokens [a] + " " + tokens [b]);
}
public static void checkThreeKind (String [] tokens)
{
for (int a = 0; a < 3; ++a)
if (num (tokens [a]) == num (tokens [a+1]))
for (int b = 2; b < 5; ++b)
if (num (tokens [a]) == num (tokens [b]))
System.out.print (tokens [a] + " " + tokens [a+1] + " " + tokens [b]);
}
static void checkTwoPair (String [] tokens)
{
for (int i = 0; i < 5; i++)
for (int j = 1; j < 5; j++)
//First Increment is pair 1 2, followed by 1 3, 1 4, and 1, 5 then 2 3, 2 4, 2 5, then 3 4, 3 5 then 4 5
if (num (tokens [i]) == num (tokens [j]))
for (int y = 0; y <= 4; y++)
for (int x = 1; x <= 4; x++)
if ((i != y) && (j != x) && (y != x) && (i != j))
if (num (tokens [y]) == num (tokens [x]))
if ((tokens [i] != tokens [j]) && (tokens [i] != tokens [y]) && (tokens [j] != tokens [y]) &&
(tokens [i] != tokens [x]) && (tokens [j] != tokens [x]) && (tokens [y] != tokens [x]))
eblock (tokens);
}
static void checkHighFlush (String [] tokens)
{
if (suit (tokens [0]) == suit (tokens [1]) &&
suit (tokens [0]) == suit (tokens [2]) &&
suit (tokens [0]) == suit (tokens [3]) &&
suit (tokens [0]) == suit (tokens [4]))
{
String outputString = "";
for (int i = 0; i < tokens.length; i++)
outputString += tokens [i] + " ";
System.out.println (outputString);
System.exit (0);
}
for (int i = 0; i <= 4; i++)
for (int j= 1; j<= 4; j++)
//First Increment is pair 1 2, followed by 1 3, 1 4, and 1, 5 then 2 3, 2 4, 2 5, then 3 4, 3 5 then 4 5
if (suit (tokens [i]) == suit (tokens [j]))
for (int y = 0; y <= 4; y++)
for (int x = 1; x <= 4; x++)
if ((i != y) && (j != x) && (y != x) && (i != j))
{
if (suit (tokens [i]) == suit (tokens [x]) &&
suit (tokens [i]) == suit (tokens [y]))
{
if ((tokens [i] != tokens [j]) && (tokens [i] != tokens [y]) && (tokens [j] != tokens [y]) &&
(tokens [i] != tokens [x]) && (tokens [j] != tokens [x]) && (tokens [y] != tokens [x]))
eblock (tokens);
}
}
}
static void checkFourKind (String [] tokens)
{
if (num (tokens [0]) == num (tokens [1]))
{
if (num (tokens [0]) == num (tokens [2]))
if (num (tokens [0]) == num (tokens [3]) || num (tokens [0]) == num (tokens [4]))
eblock (tokens);
if (num (tokens [0]) == num (tokens [3]))
if (num (tokens [0]) == num (tokens [4]))
eblock (tokens);
}
if (num (tokens [1]) == num (tokens [2]))
if (num (tokens [1]) == num (tokens [3]))
if (num (tokens [1]) == num (tokens [4]))
eblock (tokens);
}
static void checkStraight (String [] tokens)
{
int [] ints = new int [5];
for (int i = 0; i <= 4; i++)
{
switch (num (tokens [i])) {
case 'T': ints [i] = 10;
case 'J': ints [i] = 11;
case 'Q': ints [i] = 12;
case 'K': ints [i] = 13;
case 'A': ints [i] = 14;
default: ints [i] = num (tokens [i]) - '0';
}
}
for (int i = 0; i <= 3; i++)
for (int j= 1; j<= 4; j++)
//First Increment is pair 1 2, followed by 1 3, 1 4, and 1, 5 then 2 3, 2 4, 2 5, then 3 4, 3 5 then 4 5
if ((ints [i]+1) == ints [i+1])
for (int y = 0; y <= 4; y++)
for (int x = 1; x <= 4; x++)
if ((i != y) && (j != x) && (y != x) && (i != j))
{
if (ints[i] + 2 == ints[y] && ints[i] + 3 == ints [x])
{
if ((tokens [i] != tokens [j]) && (tokens [i] != tokens [y]) && (tokens [j] != tokens [y]) &&
(tokens [i] != tokens [x]) && (tokens [j] != tokens [x]) && (tokens [y] != tokens [x]))
{
for (int a : new int[] {i, j, y, x})
System.out.print (tokens [a] + " ");
System.out.println ();
System.exit (0);
}
}
java.util.Arrays.sort (ints);
if (( (ints [i]+1 == ints [j]) && (ints [i]+3 == ints [y]) && (ints [i]+4 == ints [x])))
{
for (int a : new int[] {i, j, y, x})
System.out.print (tokens [a] + " ");
System.out.println ();
System.exit (0);
}
}
}
static void checkHighCard (String [] tokens)
{
int [] ints = new int [5];
for (int i = 0; i <= 4; i++)
{
switch (num (tokens [i])) {
case 'T': ints [i] = 10;
case 'J': ints [i] = 11;
case 'Q': ints [i] = 12;
case 'K': ints [i] = 13;
case 'A': ints [i] = 14;
default: ints [i] = num (tokens [i]) - '0';
}
}
int marker = 0;
if (ints [0] > ints [1]) marker = 1;
if (ints [1] > ints [2]) marker = 2;
if (ints [2] > ints [3]) marker = 3;
if (ints [3] > ints [4]) marker = 4;
System.out.println (tokens [marker]);
}
static void eblock (String[] tokens)
{
for (int i = 0; i < 5; i++)
System.out.print (tokens [i] + " ");
System.out.println ();
System.exit (0);
}
static void checkFullHouse (String [] tokens)
{
String [] test = new String [5];
int counter = 0;
int sum = 0;
for (int i = 0; i <= 4; i++)
test [i] = tokens [i];
for (int i = 0; i <=4; i++)
{
for (int j = 1; j <= 4; j++)
{
if (num (test [i]) == num (tokens [j]))
counter++;
}
if (counter > 1)
sum++;
counter = 0;
}
if (sum == 5) eblock (tokens);
}
public static void main (String [] args) throws IOException
{
String inputString = new BufferedReader (new InputStreamReader (System.in)).readLine ();
String [] tokens = inputString.split (" ");
java.util.Arrays.sort (tokens);
checkFourKind (tokens);
checkHighFlush (tokens);
checkFullHouse (tokens);
checkStraight (tokens);
checkTwoPair (tokens);
checkThreeKind (tokens);
checkPair (tokens);
checkHighCard (tokens);
}
}