[mwdsmith]
> Below is my code for checking for a full house (when rolling
> with 5 dice).

There are many ways to do this.  Here's one:

.def isfullHouse(hand):
.    counts = [hand.count(card) for card in set(hand)]
.    return (3 in counts) and (2 in counts) and len(hand)==5


And here's a one-liner:

.def isfullHouse(hand):
.    return sorted(hand.count(card) for card in set(hand)) == [2,3]


Raymond Hettinger

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to