Forum Discussion
Challenge - Evaluate a Poker hand
i don't improvement on what you did per se but think a slightly more interesting challenge is to COMPARE 2 hands. To do this I reworked the Lambda a bit to output an integer value for what level hand it is and a decimal value for the individual cards in order of precedence. probably a more efficient way but see attached. note I also inserted logic to identify 'invalid hands' as either not enough cards or duplicate cards but I don't check for duplicate cards between the 2 hands.
PS - it just occurred to me that this modified output could be useful if this challenge was to get extended to 7 card stud or texas hold'em or include wild card to check each permutation and find the best option
I think the challenge becomes very hairy once tie breaking elements are introduced. I think you've tackled it as best as it can be done. I went back and fourth on modifying the existing function versus creating a new function to run the tie break based on the evaluation. At some point "scope creep" comes into play and things tend to get convoluted!
The way I see the tie-breaking:
It becomes a question if it's best to develop the function to handle poker variants instead of breaking ties which may not be terribly common? (Maybe a question for poker aficionados).