Tony Meyer wrote: > [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).
It *is* slower as written, although a more optimized version using itertools and sets (left as an exercise for the bored) gets close to yours. I don't think memory is an issue with 5-element lists of small integers. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list