/****************************************************
* By Rohun Bansal
* Harvard-Westlake
School
* North Hollywood,
CA.
****************************************************/
import java.io.*;
import java.util.*;
public class RohunPinochle
{
public static
void main(String[] args){
Scanner
programScanner = new Scanner(System.in);
Scanner
fileScanner = null;
File f =
null;
System.out.print("Input File Name: ");
String input
= programScanner.nextLine().trim();
f = new
File(input);
boolean
fileFound = false;
while
(!fileFound)
{
try
{
fileScanner = new Scanner(f);
fileFound = true;
}
catch
(FileNotFoundException e)
{
System.out.print("File not found.
Try again.\nInput file path or name: ");
input
= programScanner.nextLine().trim();
f =
new File(input);
}
}
ArrayList<String> lines = new ArrayList<String>();
while
(fileScanner.hasNext())
lines.add(fileScanner..nextLine().trim());
String[]
cards = new String[4];
String[] con
= {"D", "C", "S", "H"};
String[] cdz
= {"A", "K", "Q", "J"};
int[] pts =
{10, 8, 6, 4};
for (int x =
0; x < lines.size(); x++){
int
points = 0;
String[]
inn = lines.get(x).split("\\W+");
int trump
= trmp(inn[1]);
for(int y
= 2; y < 6; y++){
cards[y-2] = inn[y];
}
int
nums[][] = new int[4][4];
for(int y
= 0; y < 4; y++){
String c = cards[y];
for(int z = 0; z < 4; z++){
nums[y][z] = contains(c, cdz[z]);
}
}
for(int y
= 0; y < 4; y++){
boolean allone = true; boolean alltwo = true;
for(int z = 0; z < 4; z++){
if(nums[z][y] != 2)
alltwo = false;
if(nums[z][y] == 0)
allone = false;
}
if(alltwo){
points += pts[y] * 10;
}
if(allone){
points += pts[y] *
((alltwo) ? 2 : 1);
}
}
if(nums[0][3] == 2 && nums[2][2] == 2){
points += 30;
}
if(nums[0][3] >= 1 && nums[2][2] >= 1){
points += 4 * Math.min(nums[0][3],
nums[2][2]);
}
boolean
allonez = true; boolean alltwoz = true;
for(int z
= 0; z < 4; z++){
if(nums[trump][z] != 2)
alltwoz = false;
if(nums[trump][z] == 0)
allonez = false;
}
int zzz =
contains(cards[trump], "T");
if(alltwoz && zzz == 2){
points += 150;
}
if(allonez & zzz != 0){
points += 15 * ((alltwoz && zzz == 2) ? 2 : 1);
for(int ab = 0; ab < 4; ab++){
nums[trump][ab]--;
}
}
if(nums[trump][1] >= 1 && nums[trump][2] >= 1){ points +=
4 * Math.min(nums[trump][1], nums[trump][2]);
}
for(int z
= 0; z < 4; z++){
if(z
!= trump){
if(nums[z][1] >= 1 && nums[z][2] >= 1){
points += 2 * Math.min(nums[z][1], nums[z][2]);
}
}
}
System.out.println((x+1) + ". " + points);
}
}
public static int
contains(String a, String b){
String[] c =
a.split(""); int abc = 0;
for(int x =
0; x < c.length; x ++){
if(c[x].equals(b))
abc++;
}
return abc;
}
public static int
trmp(String cd){
String[] con
= {"D", "C", "S", "H"};
for(int x =
0; x < 4; x++){
if(con[x].equals(cd))
return x;
}
return -1;
}
}