## 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.

### 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:
**a**_{1}b_{1}a_{2}b_{2}a_{3}b_{3}a_{4}b_{4}a_{5}b_{5}- where
**a**are card values from the set_{1..5}*[2,3,4,5,6,7,8,9,T,J,Q,K,A]* - where
**b**are suit values from the set_{1..5}*[h,d,s,c]* - this string represents a sequence of five community cards that comprise the BOARD.

- where
- the following
**n**lines of each test case contain the sequence:**a**_{1}b_{1}a_{2}b_{2}- where
**a**are card values from the set_{1..2}*[2,3,4,5,6,7,8,9,T,J,Q,K,A]*(same as above) - where
**b**are suit values from the set_{1..2}*[h,d,s,c]*(same as above) - this string represents a sequence of two cards that comprise each player's hand.

- where

Annotated Example:1# one test case to follow3# three player hands in this test caseAh 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

Input | Output |
---|---|

3 4 4h 2s 4s 7d 8d Tc 4d As 3h |
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).

### 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?

- Write your program according to the problem description
- Download the basic input set. The timer will start.
- Feed the input file to your program and save the output.
- 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.
- If the timer expires. You may try again, but a new input file will be generated.
- 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.