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
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
[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
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',
>>
[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
"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',
>
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
[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
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
[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
-)
> 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
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
> 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]:
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
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
15 matches
Mail list logo