Page 2 of 4

Re: Problem 054

Posted: Fri Jul 09, 2010 12:24 pm
by MaJJ
Is solution
Expand
539
anywhere near the real answer? Bah, I wish I knew where is my error in the code ... :D

Re: Problem 054

Posted: Fri Jul 09, 2010 2:51 pm
by jaap
Majj,
Not really. It is far enough away that checking one or two dozen cases from the file at random has a good chance of finding a wrong one.

Re: Problem 054

Posted: Fri Jul 09, 2010 7:50 pm
by MaJJ
heh ... I had really nice error :D

Code: Select all

wins += 1 if s1 < s2
instead of

Code: Select all

wins += 1 if s1 > s2

Re: Problem 054

Posted: Tue Jul 27, 2010 7:59 pm
by dnosrc
can aces play low in streets?
example: A 2 3 4 5

Re: Problem 054

Posted: Tue Jul 27, 2010 8:35 pm
by elendiastarman
dnosrc wrote:can aces play low in streets?
example: A 2 3 4 5
Yes.

Re: Problem 054

Posted: Thu Apr 21, 2011 4:32 pm
by beastmaster
Hi!
i've spent a lot of time on this problem and i keep getting the same result, xxx wins for player 1, which of course is wrong. Any tips on this one? i can add code too, but i'm not sure if that's ok.

Re: Problem 054

Posted: Thu Apr 21, 2011 5:43 pm
by Lord_Farin
beastmaster wrote:Hi!
i've spent a lot of time on this problem and i keep getting the same result, xxx wins for player 1, which of course is wrong. Any tips on this one? i can add code too, but i'm not sure if that's ok.
I recall that I spent ages on this problem, rewriting my code over and over again, and keeping the same problem. In the end, it turned out I read the file wrong. So please make sure it's not something as trivial as that before spending time on rewriting all your algo's

Re: Problem 054

Posted: Sun Apr 24, 2011 12:30 pm
by beastmaster
i found the problem, it was even more trivial and it only changed the result by 1. and i spent hours and hours trying to figure it out.

Re: Problem 054

Posted: Mon May 23, 2011 6:40 pm
by Hibernatus34
Hello,

It was a nice problem, but it's a shame some cases are missing :
- Straight starting with an ace (meaning the highest card in the straight is 5)
- Four of a kind
- Straight flush and royal flush

The first case would have added a nice trap to fall into.

BTW, how fast is the function supposed to be ?
I got 1.17 ms including file loading (but not the first read so it's in a cache somewhere), i expected less.

Re: Problem 054

Posted: Sat Jul 30, 2011 2:04 pm
by matts1
Could someone remove beastmaster's post. It states the answer he got, then he said that he was off by 1

Re: Problem 054

Posted: Sat Jul 30, 2011 2:20 pm
by hk
matts1 wrote:Could someone remove beastmaster's post. It states the answer he got, then he said that he was off by 1
It need not be removed, but only edited, which I did.
BTW: the removed answer given wasn't off by one actually.

Re: Problem 054

Posted: Sat Jul 30, 2011 3:26 pm
by matts1
Thanks. Also, would someone be able to take a look at my code for this (python). I'm afraid it's quite ugly and hard to read, but it looks like there is no problem with it (that's what I thought anyway).

Re: Problem 054

Posted: Mon Aug 01, 2011 7:34 am
by thedoctar
You can pm me your code

Re: Problem 054

Posted: Fri Oct 07, 2011 5:10 am
by olleicua
I'm not sure what I'm doing wrong here, my code seems to be working fine but I get the wrong number. I put in a bunch of print statements and hunted at random for places where it was coming to the wrong conclusion in hopes of finding a systematic error but found nothing. I thought I might be confused as to which high card is used in the case of for example:

6D 6S 7D 2C 3H | 5D 5H JH 2S 7S

Initially I was thinking that since player 1's pair was 6s as opposed to player 2's 5s that player 1 would win, then I thought maybe this was not the case and the tie would just immediately send us to high card (player 2 wins). I tried this but the number I got is still wrong. Could someone look at my code and point me in the right direction?

Peace
~Sam

Re: Problem 054

Posted: Fri Oct 07, 2011 6:27 am
by TripleM
Hand 1 provided in the problem demonstrates exactly what to do in that case, namely that the pair is compared first.

I'll look at your code, as long as you don't expect more than an extremely subtle hint :)

Re: Problem 054

Posted: Wed Apr 04, 2012 7:18 am
by Eventhorizon
EDIT: Figured it out, problem with 3 of a kind.

PLUS: Suggestion to anyone else trying to verify their ranking algo: see if your counts of each type of hand (2 pair, 3 of a kind, etc) matches expectations - I found I had a count of 3 of a kind that had only a 0.08% probability. You can find the probs on Wikipedia.


So I thought it was about time I knocked this one off! I have checked the first 300 hands and my scoring algo agrees with my eye. I can't seem to get the number right but notice a couple things:

By hand 300, player1 has only won 112 hands (150 - 112) / sqrt(300 * 0.5 * 0.5) = 4.4 std devs below expectation! Still, my hand count agrees with this. Maybe player1 is the patsy!

Trying to figure out where I went wrong without spoiling it for others, I tracked the following statistics:

Out of 1000 hands 626 were decided on rank alone (i.e. FH beats Flush beats Straight beats 3 of a kind beats 2 pair beats 1 pair beats no hand)

159 matched rank and were decided on the highest value of involved cards (using the 3 from FH, highest pair of 2 pair).

0 required going to the second pair in 2 pair or the pair in the FH.

215 were then decided by the highest value of uninvolved cards.

Does this match with anyone else's experience?

Re: Problem 054

Posted: Sat Aug 18, 2012 3:35 pm
by SoboLAN
Given that I'm a computer science student with a big passion for poker, I have to say this was my absolute favourite problem. If you would make a similar one involving Omaha instead of Texas Hold'em, that would be golden :) .

PS: For those who don't know: Omaha is similar to Texas Hold'em (the poker variation that is present here in problem 54) with the exception that there are 9 cards. The best 5 cards combination (like in this problem) must then be found from these 9 cards, but there are some additional rules involved. It's interesting, trust me :) .

Re: Problem 054

Posted: Fri Aug 24, 2012 7:17 am
by Loers
this problem is reeeeally annoying ,,
in the case that two players have have 2 pairs.. how do I decide ?
what if the player A got (a pair of threes) and (a pair of queens)
while player B got (a pair of fives) and a pair of (jacks)
is there some sorta of comparing that can be done here ? or should we move to comparing highest card ?

for (one pair , four of a kind , three of kind,straight , flush , straight flush) I think that we compare the values of the winning set ,then move to highest card comparing..
but what if two got (Royal Flush) ?

and what if Highest card test fails ?!

Re: Problem 054

Posted: Fri Aug 24, 2012 7:31 am
by TripleM
You always start with the highest frequency, and then work from highest ranked to lowest ranked.

For example, if both hands are two pairs, compare the highest pair. If they are equal, compare the second highest pair. If they are equal, compare the 5th card.

If both hands are three-of-a-kind, first compare the three-of-a-kind; if equal, compare the next highest card; if equal compare the next highest card, etc. For full houses, you compare the three-of-a-kind before the two-of-a-kind. For high card only, you compare them from highest to lowest.

The problem says there is always a clear winner, so you will never have two royal flushes, and the high card test never 'fails'.

Re: Problem 054

Posted: Fri Aug 24, 2012 4:30 pm
by Loers
my code is giving me
all the following cases never appeared in the file {
Three of a Kind vs Three of a Kind
Straight vs Straight
Flush vs Flush
Full House vs Full House
Four of a Kind vs Four of a Kind
Straight Flush vs Straight Flush
Royal Flush vs Royal Flush(the only one that makes sense)
}
is that true !?!?!