Joker
InterviewTime limit1sMemory limit1024 MB
Given four cards and a joker, find the replacement card that makes the highest poker hand without duplicating a card already held.
- Level
Easy3 of 10
- Topics
- Brute force, Implementation
- Solved
- No attempts yet
Problem
You are given four poker cards and one joker card. When evaluating the poker hand, the joker card can be replaced with any card you want. However, it cannot be replaced with a card you already have. For example, if you already have 6 of hearts, the joker cannot be changed to 6 of hearts.
Find which card the joker should be changed to in order to get the highest hand. The list of hands is in the hint section below. If two hands fall into the same category, they are treated as equal. That is, suits are not ranked.
Input
Four lines are given. The i-th line contains integers and .
is the suit of the i-th poker card. 0 is clubs, 1 is diamonds, 2 is hearts, and 3 is spades.
is the rank of the i-th poker card. 1 is ace, 2 to 10 are the number cards, 11 is jack, 12 is queen, and 13 is king.
Output
Print two integers and on the first line. They are the suit and rank of the card the joker should be changed to, using the same encoding as the input.
If multiple answers exist, print any of them.
Constraints
Hint
The hands are listed below from highest to lowest.
- Straight flush: five cards of the same suit with consecutive ranks.
- Quadruple: four cards of the same rank.
- Full house: three cards of the same rank plus two other cards of the same rank.
- Flush: five cards of the same suit.
- Straight: five cards with consecutive ranks.
- Triple: three cards of the same rank.
- Two pair: two pairs.
- Pair: two cards of the same rank.
A hand that meets several conditions at once is scored as the highest hand it meets.