"Raymond Hettinger" <[EMAIL PROTECTED]> writes:
> Your use case for gathering roll statistics probably needs a more
> general solution:
> 
> hands = {
>     (1,1,1,1,1): 'nothing',
>     (1,1,1,2): 'one pair',
>     (1,2,2): 'two pair',
>     (1,1,3): 'three of a kind',
>     (2,3): 'full house',
>     (1,4): 'four of a kind',
>     (5): 'flush (five of a kind)'
> }
> 
> def eval_hand(hand):
>     counts = tuple(sorted(hand.count(card) for card in set(hand)))
>     return hands.get(counts, 'misdeal')
1. "Flush" means 5 cards of the same suit (i.e. all hearts), not 5 of
   a kind.

2. That code doesn't detect flushes or straights.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to