Page 4 of 4
problem 054 needs updated wording
Posted: Wed May 03, 2017 5:00 pm
by tommyjcarpenter
I am a poker player, and at least in HoldEm an Ace can start a straight. The wording on the problem is incorrect and ambiguous, because from it it would seem that an ace can only end a straight as in TJQKA because of the value listing, but A1234 is a valid poker straight.
So can an ace start a straight and can this be clarified in the wording?
Re: problem 54 needs updated wording
Posted: Wed May 03, 2017 6:17 pm
by rayfil
Being a new member on this forum, please be advise that problem numbers are listed with leading "0s" to provide a 3-digit number in order to facilitate archiving and easier searching.
Re: Problem 054
Posted: Tue Aug 15, 2017 4:16 pm
by th72
Hi! This one really has me stumped.
I've been doing random checks on the winning hands, but I really can't find the mistake. And I'm pretty sure I've evaluated the tie-breakers properly (again, random checks seem to work).
Would anyone be willing to take a look at my list of who won which hand and tell me the first result I've gotten wrong? I think that would put me on the right track, thanks!
Re: Problem 054
Posted: Tue Aug 15, 2017 5:10 pm
by rayfil
th72
Send me a PM with your list and I'll try to have a look at it.
Re: Problem 054
Posted: Fri Sep 20, 2019 1:40 pm
by Junglemath
I've seen conflicting answers about whether an ace can be considered the lowest card for the purposes of making a straight. In every version of (high) poker, which this problem seems to be about, the lowest straight is A2345, with the ace assuming the value of 1. For all other purposes it is considered to rank above a king.
Does anyone know for sure what this problem wants?
And to the admins, if A2345 does not count as a straight, it should be changed. This is extremely nonstandard. At the very least, a sentence should be included in the problem statement as this is a huge ambiguity to anyone who knows anything about poker.
Thanks
Re: Problem 054
Posted: Fri Sep 20, 2019 9:47 pm
by LilStalker
I do think this is considered a straight 5 high.
Are there many hands where this is a problem? Otherways you can try 2 or 3 values if there are a few hands with this occurence.
Re: Problem 054
Posted: Sat Sep 21, 2019 2:39 am
by Junglemath
LilStalker wrote: Fri Sep 20, 2019 9:47 pm
I do think this is considered a straight 5 high.
Are there many hands where this is a problem? Otherways you can try 2 or 3 values if there are a few hands with this occurence.
Someone on reddit claimed they solved it without assuming that the ace counts as low. I tried it this way and indeed I got the right answer.
BTW, did you really solve 509 problems? Did you omit 54 for some reason?
Unlikely spoiler ahead:
(No spoilers allowed on this forum. <moderator>)
Problem 054
Posted: Tue May 05, 2020 11:35 pm
by s4mp
I've coded a solution, but for some reason the answer i get is one off.
My only thought at the moment is that it counts a straight from a low ace (e.g A 2 3 4 5), As i haven't programmed this. Is this true? I've searched for similar posts but it seems to be getting mixed answers.
Re: Problem 054
Posted: Wed May 06, 2020 7:05 am
by Junglemath
There is a thread about this problem already. Did you look there?
viewtopic.php?f=50&t=6550
By the way, how do you know you're one off if you haven't solved it yet?
Re: Problem 054
Posted: Wed May 06, 2020 10:00 am
by s4mp
I've looked through the thread and that answers about the ace but i still cant work out why im off by one.
Is there any chance i could PM you a list of my results for each pair of hands and you let me know which one is wrong?
EDIT: I managed to solve it, no help needed anymore
Re: Problem 054
Posted: Wed May 06, 2020 1:40 pm
by Junglemath
s4mp wrote: Wed May 06, 2020 10:00 am
I've looked through the thread and that answers about the ace but i still cant work out why im off by one.
Is there any chance i could PM you a list of my results for each pair of hands and you let me know which one is wrong?
Sure. But how do you know you're one off if you haven't solved it yet?
Re: Problem 054
Posted: Wed May 06, 2020 8:13 pm
by hk
s4mp wrote: Wed May 06, 2020 10:00 am
I've looked through the thread and that answers about the ace but i still cant work out why im off by one.
Is there any chance i could PM you a list of my results for each pair of hands and you let me know which one is wrong?
EDIT: I managed to solve it, no help needed anymore
Great.
Next time please read the pink box at the top of the page carefully.
Re: Problem 054
Posted: Thu May 07, 2020 9:33 pm
by DeKlod
Junglemath wrote: Wed May 06, 2020 1:40 pm
s4mp wrote: Wed May 06, 2020 10:00 am
I've looked through the thread and that answers about the ace but i still cant work out why im off by one.
Is there any chance i could PM you a list of my results for each pair of hands and you let me know which one is wrong?
Sure. But how do you know you're one off if you haven't solved it yet?
Allow me to add my pinch of salt in s4mp's defence: any internet search on an Euler-like problem (particularly the older ones) will invariably turn up page after page of spoilers!
Now, it is everyone's decision - and in Covid times, we're all supposed to act responsibly so we do the same with Euler Project questions - but one of the cheats I personally find quite acceptable is to look up the answer. Not the algorithm that gets you there - just the actual answer.
I should state that my goal, in tackling Euler questions, is to teach myself computer programming. In formal education, there would be a tutor or teacher who would look at my code/thinking behind the code and give me some feedback: am I getting close or is my approach ridiculously wrong.
So I too have benefitted from looking up the odd answer - value - and find that I inadvertently missed setting the initial sum-value to 5 because my loop only started at 6, or some similar mistake. Easy to spot if you're a seasoned programmer, but a devilish trap for the self-taught novice.
So what I really want to say is: please can we avoid judging someone's message from the simple fact that he/she may have looked up (or inadvertently seen - that's Google for you!) the answer beforehand? The great thing about Project Euler is that it allows people like me to start self-taught coding without any pressure!
Besides: I know from bitter experience how hard it can be - again as a self-taught novice programmer - to find stupid little errors like the one s4mp might have made... Have you ever converted an integer into a double by forcing and multiplying by '1.*' only to find after hours and hours that you missed the dot and simply multiplied by '1' ...
There are enough traps for us novices - at least allow us to seek some guidance to keep us on the right track!
Here endeth the lesson
Claude
Re: Problem 054
Posted: Fri May 08, 2020 9:28 am
by hk
There's actually no need to have looked up the answer somewhere.
Some people simply try some answers around the value their program gives. Just to rule out off by one answers.
Re: Problem 054
Posted: Fri May 08, 2020 10:02 am
by DeKlod
hk wrote: Fri May 08, 2020 9:28 am
There's actually no need to have looked up the answer somwhere.
Some people simply try some answers around the value their program gives. Just to rule out off by one answers.
Never thought of that

Re: Problem 054
Posted: Wed Nov 19, 2025 8:48 am
by ksaho
I would discourage attempting to guess due to a off by 1 issue. I just had that issue with this problem and the off by 1 issue here was a fundamental misunderstanding on my part which if I had simply entered my result in with a variance of 1(+/-) I would never have figured it out.
Re: Problem 054
Posted: Mon Apr 13, 2026 7:22 am
by Vinny360
I need help, I don't know if you should treat all flushes as equal or compare the cards.

Re: Problem 054
Posted: Sat Apr 18, 2026 11:25 am
by DJohn
Vinny360 wrote: Mon Apr 13, 2026 7:22 am
I need help, I don't know if you should treat all flushes as equal or compare the cards.
The rules cover that:
But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on.
So if I have the 2, 4, 6, 8, and Jack of clubs and you have the 3, 5, 7, 9, and Jack of hearts, we both have a flush. We then look at our highest cards. They're both Jacks, so we look at the next highest. I have an 8 and you have a 9, so you've won that hand.
Re: Problem 054
Posted: Mon Apr 27, 2026 2:59 am
by Vinny360
DJohn wrote: Sat Apr 18, 2026 11:25 am
Vinny360 wrote: Mon Apr 13, 2026 7:22 am
I need help, I don't know if you should treat all flushes as equal or compare the cards.
The rules cover that:
But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on.
So if I have the 2, 4, 6, 8, and Jack of clubs and you have the 3, 5, 7, 9, and Jack of hearts, we both have a flush. We then look at our highest cards. They're both Jacks, so we look at the next highest. I have an 8 and you have a 9, so you've won that hand.
Thanks a lot. This is probably why my code went wrong
