Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Cards {
- public static void main(String[] args) throws IOException {
- /**Inputs are 4C for Four of Clubs. Jack is 11, Queen is 12, King is 13, Ace is 14*/
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- StringTokenizer st = new StringTokenizer(br.readLine());
- Set<Integer> numberSet = new HashSet<Integer>();
- Set<String> suitSet = new HashSet<String>();
- boolean flush = false;
- int[] count = {0,0,0,0,0,0,0,0,0,0,0,0,0};
- for(int i = 0; i<5; i++) {
- char[] token = st.nextToken().toCharArray();
- count[Character.getNumericValue(token[0])-1] += 1;
- numberSet.add(Character.getNumericValue(token[0]));
- suitSet.add(Character.toString(token[1]));
- }
- Arrays.sort(count);
- if (suitSet.size() == 1) {
- flush = true;
- System.out.print("flush");
- }
- if (numberSet.size() == 2) {
- if (count[12]==4)
- System.out.println("four-of-a-kind");
- else
- System.out.println("full house");
- }
- if (numberSet.size() == 3) {
- if (count[12]==3)
- System.out.println("three-of-a-kind");
- else
- System.out.println("two pairs");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement