Checking for a full house
Tony Meyer
t-meyer at ihug.co.nz
Wed May 25 22:38:23 EDT 2005
[Tony Meyer]
>> def isfullHouse(roll):
>> return len(set(roll)) != 2
[Robert Kern]
> [1, 1, 1, 1, 2] is not a full house.
Opps. I did say it was untested (that should have been == not !=, too).
What about:
def isfullHouse(roll):
return len(set(roll)) == 2 and roll.count(min(roll)) != 1 and
roll.count(max(roll)) != 1
Although your solution looks a lot nicer than this (though it may use more
memory, and might be slower).
=Tony.Meyer
More information about the Python-list
mailing list