I have an interesting problem to solve. Provided a list of players and two cards served to them and the first three community cards, the program should find the next two cards for the community to make a selected player the winner. Number of players can be from 2 to 10.
Example Inputs:
- List of players and the two cards served to them
- John - H2, C8
- David - Sk, Sq
- Sean - Ca, D7
- First three community cards : St,D2,Cj
Question? What can be the next two cards in community to make David the winner? Answer: Sj & Sa (David's best hand would be St, Sj, Sq, Sk, Sa -> Royal flush)
If I say the winner has to be John, the answer could be : S9, Sq (John's best hand would be C8, S9, St, Cj, Sq -> Straight) If I say the winner has to be Sean, the answer could be : Dq, Dk (Sean's best hand would be St, Cj, Dq, Dk, Ca -> Straight)
What would be a good approach to tackle this problem? The only way I could think of is by taking all 2 card combinations from the deck and evaluate the 7 cards for each player using something like this to find the best hand for each player and find the one in which the specific player wins. But it feels like a very brute-force approach. Any other alternate suggestions from anyone?