Badugi Poker
Time limit1sMemory limit256 MB
Given six distinct cards, each with a number 1 to 15 and a color, sort all 15 pairs by the ranking rules and print the winner first.
- Level
Medium4 of 10
- Topics
- Sorting, Implementation, Brute force, Combinatorics
- Solved
- No attempts yet
Problem
There are 30 playing cards. The front of each card shows a natural number from 1 to 15, and the back is either black or white.
A card is written with its number in hexadecimal and its color as b or w. For example, the 15 with a white back is written as fw.
Cards are paired up two at a time to play a simplified poker game. The ranks are defined as follows.
- Consecutive numbers (1 and f are consecutive.)
- Equal numbers
- Anything else
Within the same rank, further ranking is determined as follows.
- The pair with matching colors
- The larger high card
- The larger low card
- The black high card
Comparisons use the ranks above, and the next criterion is consulted only when the previous criterion does not decide the order.
Given 6 distinct cards, print every pair that can be formed from them in rank order. The order of the two cards in a pair follows the order in which the cards are given in the input.
Input
The first line gives 6 arbitrary cards. The cards are separated by ',', and no card is given more than once.
Output
Print every possible card pair in rank order, one per line.