Write a program to report the consecutive repetitions in a sequence of Poker cards. The goal is to detect consecutive subsequences of identical cards, of length , and write to the output a phrase describing each subsequence using the typical Poker names. We will consider 4 cases: "Pair" (), "Trio" (), "Poker" (), and longer repetitions (). If a card does not appear repeated in the sequence, nothing needs to be written. There’s no need to consider overlapping, only the longest consecutive subsequences have to be reported.
The input consists of a sequence of characters representing the
cards. As in the problem "Better Card", the characters for the cards are
A, 2, 3, ..., 9,
0, J, Q, and K. The
sequence of cards ends with a period, i.e., the character
'.', and it can be empty.
You must detect the consecutive repetitions of cards and write to the output the description corresponding to the number of times that the card has been repeated: "Pair of s", "Trio of s", "Poker of s" or " s!". Each description should be on a different line and in the order in which they appear in the input sequence. Refer to the public test cases for concrete examples.
In this problem, the input must be processed character by character;
if you use strings or any method to store the card
sequence, the problem will be considered invalid. Also,
note that the sequence is supposed to come from an unlimited source of
cards, so no maximum length can be assumed.
Input
11.
Output
Pair of 1s
Input
JJJ8A.
Output
Trio of Js
Input
122333KKKK9.
Output
Pair of 2s Trio of 3s Poker of Ks
Input
1AAAAA5QQQQQQQQ7.
Output
5 As! 8 Qs!