I relied on enumerations. In both parts I sorted a vector containing all the hands. For part 2, I used an array over the enumerations, to remap the cards’ ranks:
New_Ranking : constant array (Face) of Natural := [Jack => 0, One => 1, Two => 2, Three => 3, Four => 4, Five => 5, -- etc.
That, and a rewrite of the ordering in part 1, did the trick.
I also used enumerations but I did it a bit closer to the parsing and used
type Camel_Card is
('2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'T',
'J',
'Q',
'K',
'A');
That way I could read in a character and append single quotes on each side and use Camel_Card’Value() on it. I like your enumeration better as a client facing enumeration though.
1 Like