Problem 044
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
- zeycus
- Posts: 16
- Joined: Mon Oct 22, 2007 9:45 pm
Problem 044
In problem 44 we are required to find "the smallest pair" for which something is true. But what is the order assumed for pairs? I think it should be specified: the pair with minimal sum, the pair with the lowest maximum, the minimal pair in lexicographic order... whatever was in the mind of the problem poster.
- euler
- Administrator
- Posts: 5095
- Joined: Sun Mar 05, 2006 4:49 pm
- Location: Cheshire, England
- Contact:
Re: Problem 44 wording: "the smallest pair".
Thank you for pointing that out. It's a valid point, and reading through the forum it seems that members have mentioned it before; I wish they'd take the time like you did to post it here.
Anyway I've changed the wording to remove ambiguity, but I suspect that now it's made it into a more difficult problem than it should be. As GraemeMcRae pointed out on page 5 of the forum, members were previously arriving at the solution by simply finding the "smallest pair" and superimposing the intended interpretation (either minimal sum or difference), or no interpretation and arriving at it by chance! However, it was ambiguous as there could exist a pair Pj and Pk for which minimal j is less than the intended solution; there is simply no way to check this.
http://projecteuler.net/index.php?secti ... lems&id=44
Anyway I've changed the wording to remove ambiguity, but I suspect that now it's made it into a more difficult problem than it should be. As GraemeMcRae pointed out on page 5 of the forum, members were previously arriving at the solution by simply finding the "smallest pair" and superimposing the intended interpretation (either minimal sum or difference), or no interpretation and arriving at it by chance! However, it was ambiguous as there could exist a pair Pj and Pk for which minimal j is less than the intended solution; there is simply no way to check this.
http://projecteuler.net/index.php?secti ... lems&id=44

impudens simia et macrologus profundus fabulae
- zeycus
- Posts: 16
- Joined: Mon Oct 22, 2007 9:45 pm
Re: Problem 44 wording: "the smallest pair".
Thank you for your prompt and possitive answer. I agree the problem seems a bit more complex now, but I prefer it like this.
Cheers!
Cheers!
-
Frisker
- Posts: 6
- Joined: Thu Mar 13, 2008 3:34 pm
P44 Help
I've been trying to solve this problem for some days now, im using a method where I loop through the differences and then pick out the P(k) and P(j) that match the difference. I get a solution but the number I get isnt low enough I suppose, but I cant see what I am doing wrong.
The solution my program gives me:
If I for example try to get the numbers that produce my difference for p(15000) I get:
For p(14321) I get:
I then check if the sum of the two numbers are pentagonal.
I suppose there is something wrong with the algoritm that gives me the pentagonal numbers that got the specified difference. Anyone got any hints of what im doing wrong?.
I wish I could post some code but I suppose that it isnt allowed.
The solution my program gives me:
Expand
Expand
Expand
I suppose there is something wrong with the algoritm that gives me the pentagonal numbers that got the specified difference. Anyone got any hints of what im doing wrong?.
I wish I could post some code but I suppose that it isnt allowed.
- Tommy137
- Posts: 238
- Joined: Sun Feb 24, 2008 6:02 pm
- Location: Cologne, Germany
- Contact:
Re: P44 Help
Hi,
I used a similar method and got the correct answer, although it was awful slow. I still think it's the only way to ensure that the difference is minimized (many used faster algorithms that did not really minimize D, but nevertheless got the solution).
So I've no idea why your method doesn't work, but it's hard to say anything without seeing the code.
I can only tell you that you are far away from the correct answer
Thomas
I used a similar method and got the correct answer, although it was awful slow. I still think it's the only way to ensure that the difference is minimized (many used faster algorithms that did not really minimize D, but nevertheless got the solution).
So I've no idea why your method doesn't work, but it's hard to say anything without seeing the code.
I can only tell you that you are far away from the correct answer
Thomas

-
Frisker
- Posts: 6
- Joined: Thu Mar 13, 2008 3:34 pm
Re: P44 Help
Thanks for your reply!.
Can't you say if my examples above are correct or not? and I suppose that my answer is way too high?. I'll post the code for my method that filters out the pentagonal numbers that form the specified difference
Can't you say if my examples above are correct or not? and I suppose that my answer is way too high?. I'll post the code for my method that filters out the pentagonal numbers that form the specified difference
Expand
-
quilan
- Posts: 182
- Joined: Fri Aug 03, 2007 11:08 pm
Re: P44 Help
I may be slightly confused by your wording... but I'll give it a shotFrisker wrote:Can't you say if my examples above are correct or not? and I suppose that my answer is way too high?. I'll post the code for my method that filters out the pentagonal numbers that form the specified difference
Expand
ex ~100%'er... until the gf came along.


- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: P44 Help
Seems you're missing some:
*Penta> indices (penta 15000)
[7499826,4687384,2205808,299806,187196,87596,54126]
*Penta> indices (penta 14321)
[51271566]
Can't say what went wrong, though.
quilan, you must have a bug in your code:
p(4687360) = 32957013310720 [ne] 32957013308992 (which is not pentagonal)
*Penta> indices (penta 15000)
[7499826,4687384,2205808,299806,187196,87596,54126]
*Penta> indices (penta 14321)
[51271566]
Can't say what went wrong, though.
quilan, you must have a bug in your code:
p(4687360) = 32957013310720 [ne] 32957013308992 (which is not pentagonal)
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
quilan
- Posts: 182
- Joined: Fri Aug 03, 2007 11:08 pm
Re: P44 Help
Silly me, I was using Excel, and it came to p(4687360.99987) so err... my bad as they say. No code there.daniel.is.fischer wrote:quilan, you must have a bug in your code:
p(4687360) = 32957013310720 [ne] 32957013308992 (which is not pentagonal)
ex ~100%'er... until the gf came along.


-
Frisker
- Posts: 6
- Joined: Thu Mar 13, 2008 3:34 pm
Re: P44 Help
I've been pulling hairs to the point of baldness these last days but I finally solved it (never felt this good). The thing was that my method that checked if a number was pentagonal was flawed at big numbers (damn you Math.sqrt!), I should have figured that our earlier though, but I will never make that mistake again!.
Thanks for the help, I probably never would have seen it without that complete list. (I was double checking all the numbers from the GetNumbers method with my "IsPentagonal" function, so that's why my list did differ from the correct one)
Thanks for the help, I probably never would have seen it without that complete list. (I was double checking all the numbers from the GetNumbers method with my "IsPentagonal" function, so that's why my list did differ from the correct one)
-
incandenza
- Posts: 7
- Joined: Wed Apr 02, 2008 9:00 pm
Re: P44 Help
I wonder if it would be better to modify this question so that it is specifically asking for the value of D corresponding to the lowest pair j,k (or the lowest sum j+k or whatever), instead of the lowest D period.Tommy137 wrote:I used a similar method and got the correct answer, although it was awful slow. I still think it's the only way to ensure that the difference is minimized (many used faster algorithms that did not really minimize D, but nevertheless got the solution).
It wouldn't change the actual answer, but it seems that most people are calculating the former and just hitting the answer "by accident". If this is supposed to be one of the easier problems, might as well make it clear that the easy solution is actually valid.
Something just seems wrong about being so easily able to "get away" without checking all the possibilities.
-
Erasmus Darwin
- Posts: 1
- Joined: Tue Apr 15, 2008 4:59 pm
Re: P44 Help
You raise a good point, but I think the slightly harder wording helps in the sense that doing it properly will better prepare people for harder problems.incandenza wrote:It wouldn't change the actual answer, but it seems that most people are calculating the former and just hitting the answer "by accident". If this is supposed to be one of the easier problems, might as well make it clear that the easy solution is actually valid.
Something just seems wrong about being so easily able to "get away" without checking all the possibilities.
I noticed that there's some similar but not quite identical "cheating" that can be used for other problems such as 30 and 34. In those cases, the problems require you to find all numbers with a certain property, and no upper bound is provided. As such, you can either find a way to calculate an upper bound, or you can just keep raising the hardcoded upper bound until the answer form accepts your result. Since you'd be relying on the answer form to determine initial correctness rather than as a double-check on your own work, it obviously falls outside the spirit of the rules.
So there are at least a couple easy problems that you can get away with doing it the wrong way, but that doesn't negate the value someone derives from doing them correctly.
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: P44 Help
About the wording of Problem 44: until last fall it read
So I think if you come up with an algorithm that very probably gives the correct answer, it's good enough, then you should check the thread if somebody proved the correctness.
and it has been argued that that is ambiguous (though, for all reasonable notions of 'smallest pair', the answer is the same). It was changed to disambiguate the question. Any answer before that change is thus completely excused from not checking whether a smaller difference might exist. Answers after that change would be incomplete without that check indeed. But for many problems you can have an algorithm which gives the right answer without being able to prove that it does. And although it would be interesting to see proofs of correctness for some algorithms, I'd hate to read one for every submitted answerFind the smallest pair of pentagonal numbers for which their sum and difference is pentagonal; what is their difference?
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
incandenza
- Posts: 7
- Joined: Wed Apr 02, 2008 9:00 pm
Re: P44 Help
Yes, I'm getting more used to the idea that it's OK to just submit any answer you think has even a chance of being correct, since that seems to be more in the spirit of how things are done here.daniel.is.fischer wrote:So I think if you come up with an algorithm that very probably gives the correct answer, it's good enough, then you should check the thread if somebody proved the correctness.
Originally my attitude was that it was pretty important to be sure your algorithm was correct before submitting, and that you should probably feel pretty bad if you submit an answer and it's wrong.
- euler
- Administrator
- Posts: 5095
- Joined: Sun Mar 05, 2006 4:49 pm
- Location: Cheshire, England
- Contact:
Re: P44 Help
Just to re-iterate those sentiments...
You will know from the phrase at the bottom of the About page: "Project Euler exists to encourage, challenge, and develop the skills and enjoyment of anyone with an interest in the fascinating world of mathematics." To new members it might seem a little circular the idea of restricting access to a full discussion of the solution until you've solved it, in that once you've solved it, would you need to discuss the solution? However, for many people they have an almost workable method, but it may, for example, always give one more than the intended answer. Long standing members have become accustomed to trying one either side of their answer. To have got to that point means you have engaged the problem sufficiently enough to want to know how it works and so you will value the experience of seeing how it should be done properly, or even how it could be done with breath-taking efficiency, all the more. Simply providing problems with full access to answers and a forum at the click of a mouse would only cheapen the experience of learning; in fact, I would go as far to say that no real learning takes place.
You will know from the phrase at the bottom of the About page: "Project Euler exists to encourage, challenge, and develop the skills and enjoyment of anyone with an interest in the fascinating world of mathematics." To new members it might seem a little circular the idea of restricting access to a full discussion of the solution until you've solved it, in that once you've solved it, would you need to discuss the solution? However, for many people they have an almost workable method, but it may, for example, always give one more than the intended answer. Long standing members have become accustomed to trying one either side of their answer. To have got to that point means you have engaged the problem sufficiently enough to want to know how it works and so you will value the experience of seeing how it should be done properly, or even how it could be done with breath-taking efficiency, all the more. Simply providing problems with full access to answers and a forum at the click of a mouse would only cheapen the experience of learning; in fact, I would go as far to say that no real learning takes place.

impudens simia et macrologus profundus fabulae
-
incandenza
- Posts: 7
- Joined: Wed Apr 02, 2008 9:00 pm
Re: P44 Help
Hmm, maybe I missed your point; I don't think anyone was arguing that the answers should be given away.euler wrote:Simply providing problems with full access to answers and a forum at the click of a mouse would only cheapen the experience of learning; in fact, I would go as far to say that no real learning takes place.
To me the issue was more, how OK is it to guess? I kind of dislike the idea of guessing because in most real world situations you don't have someone just telling you whether you got the right answer; you have to know your solution is correct. So when it's possible to get the answer right with a semi-guess, I find that kind of disappointing from a problem design point of view. But that's just me.
I do see your point, though, that if you even come up with a decent guess, you've understood the problem enough that it's OK if you luck out and get to see the solutions.
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: P44 Help
incandenza wrote: To me the issue was more, how OK is it to guess? I kind of dislike the idea of guessing because in most real world situations you don't have someone just telling you whether you got the right answer; you have to know your solution is correct.
Those feelings honour you. However, in my experience, in most real world situations you don't know whether your solution is correct. Fortunately, often it doesn't matter if it is, it's only important (very important) that your solution is close enough to the correct solution. Of course, you'd better be sure about that, but often you don't have the time to be. Then, if you know enough about the matter, it's perfectly reasonable to make an educated guess. Here, if you understood the problem well enough to see that it should have that structure, but are not able to prove that no freak cases can exist, in my opinion it is legitimate to guess that they don't exist and try out what your structure gives you.
Not quite just you. But it's terribly hard to come up with problems where a talented pattern-spotter couldn't spot a successful pattern.So when it's possible to get the answer right with a semi-guess, I find that kind of disappointing from a problem design point of view. But that's just me.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
JPGargoyle
- Posts: 8
- Joined: Mon Oct 06, 2008 5:15 pm
Problem 44
Hi.
Can someone please explain to me what is meant by "D = |Pk - Pj| is minimised"?
Does |Pk - Pj| means the absolute value? or distance?, or something else?
Thanks a lot.
Best regards.
Can someone please explain to me what is meant by "D = |Pk - Pj| is minimised"?
Does |Pk - Pj| means the absolute value? or distance?, or something else?
Thanks a lot.
Best regards.
- Georg
- Posts: 157
- Joined: Mon Jan 21, 2008 7:00 am
- Location: Mannheim, Germany
- Contact:
Re: Problem 44, need explanation
|Pk - Pj| does mean the absolut value
|Pk - Pj| = Pk - Pj, if Pk - Pj ≥ 0
|Pk - Pj| = Pj - Pk, if Pk - Pj < 0
|Pk - Pj| = Pk - Pj, if Pk - Pj ≥ 0
|Pk - Pj| = Pj - Pk, if Pk - Pj < 0
- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 44, need explanation
Yes, the absolute value of the difference between the two numbers.JPGargoyle wrote:Does |Pk - Pj| means the absolute value?
This is exactly how distance is usually defined on real numbers.JPGargoyle wrote: or distance?
