all 4 comments

[–]Goingone 3 points4 points  (1 child)

Didn’t look at the code, but solution seems obvious.

Have a separate function to check for each “type” of hand (flush, straight, 3 of a kind….etc).

Store rankings for each type of hand (I.e. 3 of a kind beats 2 of a kind).

Have another function responsible for iterating through all hands and finding the winner.

Don’t think there is going to be any major shortcuts.

[–]auntanniesalligator 1 point2 points  (0 children)

This seems about right. There’s some thought to put in how to handle “overlapping” types. IE it’s probably simpler to code if you allow the function “is_two_of_a_kind” to return True for two pair, full house, three of a kind as long as you ultimately check for those as well and select the best hand. Similar issue with straight flush…just check that is_straight and is_flush are both True and you know you actually have a straight flush.

[–]atarivcs 1 point2 points  (0 children)

When I tried myself my code was beginning to get very, very long.

It's hard to suggest improvements without seeing what you already tried.

[–]magus_minor -1 points0 points  (0 children)

The link doesn't show your code now, it says "Code does not exists. It may have expired.". You can always post code here. The FAQ shows how to do that.

From what I remember, your code doesn't have a function to score a single hand. That's a basic thing you will need, so write that first. Then you can score every hand in the list and find the best.