Re: Checking for a full house

2005-05-30 Thread mwdsmith
Wow... This is amazing, I didn't know there were so many way's of doing this! Thank you every one for all your suggestions. I particularly like the sorting counting ones. And no, Roy, this isn't a home work assignment, at the moment all of those contain php and java RMI. :) -- http://mail.p

Re: Checking for a full house

2005-05-26 Thread flupke
Raymond Hettinger wrote: > [Benedict] > >>>It would be interesting to see how complicated it would get to write >>>code to detect the correct hands in poker with wildcards included. > > > There is an interesting SF project with code written in C: > http://pokersource.sourceforge.net/ > > In

Re: Checking for a full house

2005-05-26 Thread Raymond Hettinger
[Benedict] >> It would be interesting to see how complicated it would get to write >> code to detect the correct hands in poker with wildcards included. There is an interesting SF project with code written in C: http://pokersource.sourceforge.net/ In contrast, Python makes short work of these

Re: Checking for a full house

2005-05-26 Thread flupke
Paul Rubin wrote: > "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', >>

Re: Checking for a full house

2005-05-26 Thread Raymond Hettinger
[Paul Rubin] > 1. "Flush" means 5 cards of the same suit (i.e. all hearts), not 5 of >a kind. More importantly, the (5) should be (5,). Also the poker terminology should be expressed in terms of dice rolls (the OP's use case). > 2. That code doesn't detect flushes or straights. It also doe

Re: Checking for a full house

2005-05-25 Thread Paul Rubin
"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', >

Re: Checking for a full house

2005-05-25 Thread Raymond Hettinger
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)' } d

Re: Checking for a full house

2005-05-25 Thread Raymond Hettinger
[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 h

Re: Checking for a full house

2005-05-25 Thread Robert Kern
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(r

RE: Checking for a full house

2005-05-25 Thread Tony Meyer
[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

Re: Checking for a full house

2005-05-25 Thread Roy Smith
-) > So, to start me off on python, I decided to put together a little > script to test the probabilities of rolling certain combinations of > dice. Below is my code for checking for a full house (when rolling > with 5 dice). A roll is a list, eg [1, 3, 5, 1, 4] (this example is

Re: Checking for a full house

2005-05-25 Thread Robert Kern
Tony Meyer wrote: > def isfullHouse(roll): > return len(set(roll)) != 2 [1, 1, 1, 1, 2] is not a full house. -- 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/mailm

RE: Checking for a full house

2005-05-25 Thread Tony Meyer
> def removeAll(element, num2Rem, list): > l = list[:] > for num in range(0, num2Rem): > l.remove(element) > return l > > def isfullHouse(roll): > for die in range(1,7): > if roll.count(die)==3: > l = removeAll(die, 3, roll) > if l[0]==l[1]:

Re: Checking for a full house

2005-05-25 Thread Robert Kern
abilities of rolling certain combinations of > dice. Below is my code for checking for a full house (when rolling > with 5 dice). A roll is a list, eg [1, 3, 5, 1, 4] (this example is > not a full house) > > def removeAll(element, num2Rem, list): > l = list[:] > for num

Checking for a full house

2005-05-25 Thread mwdsmith
ce. Below is my code for checking for a full house (when rolling with 5 dice). A roll is a list, eg [1, 3, 5, 1, 4] (this example is not a full house) def removeAll(element, num2Rem, list): l = list[:] for num in range(0, num2Rem): l.remove(element) return l def isfull