Wheel poker hand

broken image
broken image

There are hidden complexities though in ranking hands - using supplementary cards to resolve a draw and using the face value of pairs etc. The hand rankings are as for Texas Hold'em. '2C 5C 3C 4C 6C' is a straight flush in clubs to the 6.

broken image

So 2H is the 2 of Hearts and TC is the ten of clubs etc. Poker hands are represented by strings of 2 characters separated by a space. The challenge is to rank two poker hands and decide which one wins. But it's a really nice example of how to use these tools to solve a multi-step problem in the real world. Sure enough we can press into service map and reduce to get us the information we need. The end result works well, is concise and readable (it's a lot shorter than the other proposed solutions at least). Usually if the answer is more than one or two lines of some fancy function I don't have the time, but yesterday the challenge was to rank poker hands and it struck me as one of those things that 'should' be easy! You, like me, may have a play at solving some of the daily challenges here on DEV.

broken image