Your friend invited you to a high-stakes poker game at the last minute and, as a computer scientist, you've decided to use your skills to gain an edge on the game. Your task will be, given
2 cards (your hand) and
0, 3, 4 or 5 cards (the dealt cards), you must decide what the best possible hand you can get will be. If all 7 cards are given as arguments, the answer is pretty clear. If given less, the problem becomes more complex. However, this isn't quite enough to give you the edge you're looking for, you must also calculate the best possible hand from the remaining cards to understand what your opponents could have as well.
If you don't know about hold'em, each player in the game starts with 2 cards as their 'hand'. Over the course of 3 'turns', additional cards are revealed to be shared between all players. The first turn, 3 cards are revealed. The second, 1 more, and the third time a final card is revealed. The two cards given first represent your hand, while the latter represents 0, 3, 4, or 5 cards given by the successive turns.
[2S,3S,4S,5S,6S,7S,8S,9S,TS,JS,QS,KS,AS, # Spades. 2C,3C,4C,5C,6C,7C,8C,9C,TC,JC,QC,KC,AC, # Clubs. 2H,3H,4H,5H,6H,7H,8H,9H,TH,JH,QH,KH,AH, # Hearts. 2D,3D,4D,5D,6D,7D,8D,9D,TD,JD,QD,KD,AD] # Diamonds.
1:Royal Flush (A-K-Q-J-10, all from the same suit). 2:Straight Flush (Sequential cards, all from the same suit). 3:Four-of-a-Kind (Self explanatory). 4:Full House (3-of-a-kind and a 2-of-a-kind). 5:Flush (All cards are from the same suit). 6:Straight (Sequential Cards, any suits). 7:3-of-a-Kind (Self explanatory). 8:2-Pair (Double 2-of-a-Kind). 9:Pair (2-of-a-Kind). 10:High Card (You have absolutely nothing except a single card).
Lets take an example or two and walk through them:
The simple example:
[AS, AC],[AH,AD,9S,9C,9H] ->
The best possible hand you'll have in this setup is the four of a kind hand. The best possible hand your opponents could have is also a 4-of-a-Kind, as you cannot have a KQJ10 in their 2-card hands.
2 (Straight Flush),
You're at risk for a straight flush, but because you have the 2/5C in your hand, nobody else is due to you holding both middle cards. The best they can hope for is having 2 pocket Jacks and getting a Jack on the flop.
1 (Royal Flush),
1 (Royal Flush)
No information you can use against them has been given, all you can tell at the moment is that they can only have a royal flush in diamonds/hearts, but it's just as possible that you get the royal flush as they do. In fact, all inputs where the flop has yet to happen should result in a 1-1 answer.
10 (High Card),
This is an example of where you're absolutely screwed, and there's no possibility of a straight or a flush given the river. Meaning the best hand here is pocket aces resulting in a 3-of-a-Kind.
- Input must be separated between what is in your hand and what is public knowledge; it'll likely be easier this way regardless of implementation.
- Cards can be tuples or strings, up to you.
- The Hand and the Playing Field can be arrays or delimited strings.
- Output must be two indexes from the list of hands I've provided (E.G. [2,1]).
- It may be returned as part of a function, printed to console or output in a suitable manner.
- There must be two distinct values, one for your best hand, another for the best possible.
- 10 may be represented as a
10, whichever makes sense for you.
- Standard loopholes are disallowed.
- This is code-golf, lowest byte-count with a tie-breaker of post date.