Hold'em Ranking Challenge

Closes June 23, 2012

In this challenge we're going to see how well you can analyze a hand of cards and determine its relative ranking. This is a beta-challenge to test the new features of proggitquiz.

Cards

Problem Description

Texas Hold 'em has in recent years grown to be one of the most popular games played around the world. In addition to its place in casinos, you can find Hold 'Em televised on major sports networks and played by many thousands of players on gaming websites.

The goal of your program in this challenge is to determine the winning hand (or hands) given a set of five community cards and a number of player hands, according to the rules of Texas Hold 'Em.

On the showdown, each player plays the best poker hand they can make from the seven cards comprising his two hole cards and the five community cards. A player may use both of his own two hole cards, only one, or none at all, to form his final five-card hand. If the five community cards form the player's best hand, then the player is said to be playing the board and can only hope to split the pot, because each other player can also use the same five cards to construct the same hand.

Other resources

Input

  • The first line of the input file contains integer T, the number of test cases to follow.
  • The first line of each test case contains integer n, the number of player hands in this case.
  • The second line of each test case contains the sequence: a1b1 a2b2 a3b3 a4b4 a5b5
    • where a1..5 are card values from the set [2,3,4,5,6,7,8,9,T,J,Q,K,A]
    • where b1..5 are suit values from the set [h,d,s,c]
    • this string represents a sequence of five community cards that comprise the BOARD.
  • the following n lines of each test case contain the sequence: a1b1 a2b2
    • where a1..2 are card values from the set [2,3,4,5,6,7,8,9,T,J,Q,K,A] (same as above)
    • where b1..2 are suit values from the set [h,d,s,c] (same as above)
    • this string represents a sequence of two cards that comprise each player's hand.
Annotated Example:

1                   # one test case to follow
3                   # three player hands in this test case
Ah 3d Jc Ts 6d      # community cards: A♡ 3♢ J♣ 10♠ 6♢
9s 7d               # player 0 holds 9♠ 7♢
Kc 2s               # player 1 holds K♣ 2♠
Qc Jh               # player 2 holds Q♣ J♡

Output

Your program should output T lines, one for each test case. On each line the winning player from that hand will be indicated by a zero-based index of the winner by the position in the original input. In the above example, since the third player won, the output for that line would be 2. If more than one player is tied for the win, output all winning player on the same line separated by a space. The order that you output each player should be sorted. For example: 0 3 4 and not 4 0 3.

Sample

InputOutput
3
4
4h 2s 4s 7d 8d
Tc 4d
As 3h
Qd 4c
9h Qc
3
Kd 9s 4d Jd 2h
Jh Js
As 5c
7d 4s
4
9s 7s Jd 7d Qs
Qh 9c
5h 7h
5s 9h
4h 7c
2
0
1 3

Bonus Set

As a bonus challenge, see if you can do the same thing as above, but for Omaha rules. Instead of two cards for each player, there will be four. A winning hand MUST be made up of exactly two player cards and exactly three community cards (unlike Texas Hold 'em, which may use any combination of community cards and player cards). Like above, each line of output must specify a winning hand (or hands).

The basic differences between Omaha and Texas hold 'em are these: first, each player is dealt four hole cards instead of two. The betting rounds and layout of community cards are identical. At showdown, each player's hand is the best five-card hand made from exactly three of the five cards on the board, plus exactly two of the player's own cards. Unlike Texas hold 'em, a player cannot play four or five of the cards on the board with fewer than two of his own, nor can a player use three or four hole cards to disguise a strong hand.

Limits

Basic Set

  • 80 ≤ T ≤ 100
  • 5 ≤ n ≤ 9

Advanced Set

  • 2000 ≤ T ≤ 2400
  • 19 ≤ n ≤ 23

Bonus Set (Omaha rules)

  • 49 ≤ T ≤ 51
  • 9 ≤ n ≤ 9

Basic set (50 points)

Advanced set (100 points)

Bonus set (25 points)

Runtime Bonus (15 points)

Complete advanced set within one minute of downloading file.

Earlybird Bonus (10 points)

Complete advanced set within 24 hours of challenge start.


Scoreboard

lzm bas adv bon 200
sirpengi bas adv bon 200
sixthgear bas adv bon 190
mserrano bas adv bon 190
robbinsr bas adv bon 190
synx bas adv bon 50

What do?

  1. Write your program according to the problem description
  2. Download the basic input set. The timer will start.
  3. Feed the input file to your program and save the output.
  4. Upload the output file along with your source code. If it is correct, you will receive points. If not you may try again until the timer expires.
  5. If the timer expires. You may try again, but a new input file will be generated.
  6. Repeat fot each set.

Note: The input sets use unix line endings (\n) and the verifier expects them as well.


Come Chat!

Join channel ##proggit on freenode.

Bugs

Having issues with the the site? Let us know.