Back
Close

Three card poker

Statement

 Goal

Determine the winner of a hand of three card poker (no suits).

In this game there are four possible hands. In descending order of value they are:
triple - all three cards have the same value
straight - three cards in sequential order
pair - two cards have the same value
high card - any hand not described above

If multiple hands have the same value, a tiebreaker is used:
triple - highest card wins (ties are NOT possible)
straight - highest card wins (ties ARE possible)
pair - highest pair wins, if both pairs are equal then highest third card wins (ties ARE possible)
high card - highest card wins, if equal then next highest card wins, if equal then third highest card wins (ties ARE possible)
Input
Line 1: An integer N, the number of players
Next N lines: An alphabetic string name followed by three cards X Y Z (all space-separated
Output
One line: name of winning player, or space-separated list of names (in alphabetic order) if multiple players tied
Constraints
2 <= N <= 10
1 <= X,Y,Z <= 13
1 <= length(name) <= 10
Cards are selected from a deck composed of four of each integer i from 1 to 13 inclusive
Example
Input
2
Phil 4 5 6
Melinda 4 4 4
Output
Melinda

Game modes
Fastest

Test cases
straight v triple Test
Input
2 Phil 4 5 6 Melinda 4 4 4
Output
Melinda

Validator 1 Validator
Input
2 Phil 7 8 9 Melinda 3 3 3
Output
Melinda

low straight vs high pair Test
Input
3 Daisy 5 3 4 Fitz 12 12 11 Simmons 3 5 7
Output
Daisy

Validator 2 Validator
Input
3 Daisy 7 9 8 Fitz 13 10 13 Simmons 4 6 8
Output
Daisy

tied pairs Test
Input
4 Mack 7 7 8 Elena 7 8 7 Bobbi 3 4 6 Hunter 3 2 3
Output
Elena Mack

Validator 3 Validator
Input
4 Mack 7 4 5 Elena 3 3 4 Bobbi 9 10 9 Hunter 9 9 10
Output
Bobbi Hunter

pair tiebreaker Test
Input
5 Ward 12 12 13 Garrett 12 10 12 Malick 11 11 13 Ophelia 13 11 11 Hale 10 9 10
Output
Ward

Validator 4 Validator
Input
5 Ward 12 12 13 Garrett 12 10 12 Malick 11 11 13 Ophelia 13 11 11 Hale 10 9 10
Output
Ward

straight tiebreaker Test
Input
3 Jiaying 4 6 5 Calvin 9 8 7 Daisy 2 3 4
Output
Calvin

Validator 5 Validator
Input
3 Jiaying 7 8 6 Calvin 9 8 10 Daisy 5 3 4
Output
Calvin

high card tiebreaker Test
Input
4 Talbot 11 10 8 Whitehall 7 12 10 Raina 12 10 9 Creel 11 7 10
Output
Raina

Validator 6 Validator
Input
4 Talbot 11 10 6 Whitehall 8 13 10 Raina 13 10 9 Creel 11 6 10
Output
Raina

The big one Test
Input
10 A 8 10 11 B 1 3 10 C 2 3 5 D 8 10 12 E 2 5 12 F 2 6 13 G 1 4 11 H 6 12 13 I 7 8 13 J 6 9 11
Output
H

Validator 7 Validator
Input
10 A 3 4 9 B 5 13 11 C 2 8 13 D 3 7 8 E 3 10 12 F 5 11 13 G 1 5 6 H 7 9 13 I 4 6 9 J 1 2 5
Output
B F

Solution language

Solution

Stub generator input