#K75067. Determine if a Poker Hand is a Straight
Determine if a Poker Hand is a Straight
Determine if a Poker Hand is a Straight
In this problem, you are given a hand of five playing cards. Each card is described by its rank and suit. Your task is to determine whether the hand forms a "Straight" in poker.
A hand is considered a Straight if the five cards have consecutive ranks and no duplicates. Note that the Ace (represented by 14) can be used either as the highest card or as the lowest card in a straight. In other words, a hand is a Straight if, after sorting the ranks into \( r_1, r_2, r_3, r_4, r_5 \), either:
- \( r_{i+1} = r_i + 1 \) for \( i = 1, 2, 3, 4 \), or
- the ranks are exactly \( 2, 3, 4, 5, 14 \) (which represents the Ace-low straight).
You need to implement a program that reads 5 cards from standard input and prints "True" if the cards form a Straight and "False" otherwise.
inputFormat
The input consists of 5 lines. Each line contains a rank and a suit separated by a space. The rank is an integer and the suit is a string (one of: hearts, diamonds, clubs, spades).
Example:
10 hearts 11 diamonds 12 clubs 13 spades 14 hearts
outputFormat
Print a single line: "True" if the hand forms a Straight, otherwise "False".
## sample10 hearts
11 diamonds
12 clubs
13 spades
14 hearts
True
</p>