Poker face X46281


Statement
 

pdf   zip

html

Here, you are asked to write a program that receives a sequence of poker hands, and evaluates whether or not each is a straight, flush, or a straight flush. A hand here consists of 5 cards; each card is specified by a value (an int between 1 and 13, inclusive) and a suit (an int between 0 and 3, inclusive; 0 represents clubs, 1 represents diamonds, 2 represents hearts, and 3 represents spades). A hand is defined to be a straight if the values are—up to reordering—5 consecutive values, where the ace value (1) may be the highest or the lowest; it is defined to be a flush if all of the suits are the same; and, it is defined to be a straight flush if it is both a straight and a flush.

Input

A number n ≥ 1, followed by n hands.

Output

For each hand, output two lines:

On the first line, print out the cards in the hand in a comma-separated sequence, using the word Ace to represent the value 1, Jack to represent the value 11, Queen to represent the value 12, and King to represent the value 13. Follow the examples.

On the second line, output “Straight flush” if the hand is a straight flush, “Straight” if the hand is a straight but not a flush, “Flush” if the hand is a flush but not a straight, and “None” otherwise.

Observation

Public test cases
  • Input

    1 
    1 1 2 1 3 1 4 1 5 1
    
    
    

    Output

    Ace of Diamonds, 2 of Diamonds, 3 of Diamonds, 4 of Diamonds, 5 of Diamonds
    Straight flush
    
  • Input

    1 
    1 1 13 1 12 1 10 1 11 2
    
    
    

    Output

    Ace of Diamonds, King of Diamonds, Queen of Diamonds, 10 of Diamonds, Jack of Hearts
    Straight
    
  • Input

    2 
    2 3 3 3 4 3 5 3 6 3 
    7 0 8 1 9 2 10 3 10 0
    
    
    

    Output

    2 of Spades, 3 of Spades, 4 of Spades, 5 of Spades, 6 of Spades
    Straight flush
    7 of Clubs, 8 of Diamonds, 9 of Hearts, 10 of Spades, 10 of Clubs
    None
    
  • Information
    Author
    Hubie Chen
    Language
    English
    Official solutions
    Java
    User solutions
    Java