-- Mark Twain
Texas hold'em is a variation of the standard card game of poker. Two cards (hole cards) are dealt face down to each player and then five community cards are placed face-up by the dealer. And when all openings we need to define what is the combination a player have.
You are given a sequence of 7 cards and you should choose the best hand (5 cards) in it. Card sequence are described as a string, where each card are defined by two character - rank and suit. Cards separated by commas.
The descending ranks are: "A" (Ace), "K" (King), "Q" (Queen), "J" (Jack), "T" (Ten), and "9" to "2".
The descending suits are "h" (hearts), "d" (diamonds), "c" (clubs), "s" (spades).
Texas holdem uses the classical poker hand list : Straight flush, Four of a kind, Full house, Flush, Straight, Three of a kind, Two Pair, One Pair and High card.
Because of the presence of community cards in Texas hold 'em, different players' hands can often come very close in value. As a result, it is common for kickers to be used to determine the winning hand for cases where two or more hands tie. A kicker is a card which is part of the five-card poker hand, but is not used in determining a hand's rank. For instance, in the hand A-A-A-K-Q, the king and queen are kickers.
In our version of Texas Hold'em cards of differing suits have different values. This means that there is only ever one best five-card hand to return. So "Td" is higher than "Tc", but lower then "Jc".
Your goal is to choose the best hand with 5 cards and return them as a string, where cards are separated by commas and ordering from the highest to lowest value. For example: We have two pair by queens (heart and spades) and eights (diamonds and clubs) and nine heart as a kicker. The result: "Qh,Qs,9h,8d,8c". Be careful with order.
Input: A list of cards as a string.
Output: The best hand as a string.
How it is used: This concept is a good example of combinatorial optimisation process, and could come in handy should you make a poker game in Python.
cards_quantity == 7 All cards correct and unique.
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin --ff
checkio install-plugin --chromium