#C4851. Identify Card Hand Type
Identify Card Hand Type
Identify Card Hand Type
You are given a hand of five playing cards. Each card is represented by a rank and a suit (for example, 2H
for the 2 of Hearts or QD
for the Queen of Diamonds).
The task is to determine whether the hand forms a flush or a straight flush. A flush is defined as all cards having the same suit. Moreover, if the flush cards are in consecutive order, then the hand is a straight flush.
For a straight flush, output the rank of the highest card followed by SF. If the hand is a flush but not consecutive, output only F. Otherwise, output N.
Additional Information: The rank values are given by the following order in increasing value: \(2,3,4,5,6,7,8,9,10,J,Q,K,A\), where \(A\) (Ace) is the highest.
inputFormat
The input consists of a single line with five space-separated strings. Each string represents a card.
outputFormat
Print a single string that indicates the type of hand: if the hand is a straight flush, output the highest card's rank followed by SF
; if it is a flush (but not consecutive), output F
; otherwise, output N
.
2H 3H 4H 5H 6H
6SF