Problem 125

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
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.

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


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
pills
Posts: 4
Joined: Tue Aug 26, 2008 9:16 am

Problem 125

Post by pills »

Hello all,

I'm stuck on problem 125. Although the algorithm seems simple and the code I wrote works for the example, I'm stuck with the "Sorry..." page when I try it for 10^8.
I've rewritten the code 3 times and always come up with the same answer, which leads me to believe I missed something in the problem itself.
Here are the answers (sum and number of palindromes) I get for 10^3, 10^4, ... ,10^8 :
Expand
4164 11
20268 17
667526 30
15447478 60
313698021 112
snip
Any help or pointers are appreciated... I'm sure I'll have a "D'oh" moment when I figure out the answer, but I've been thinking about this problem so much that I just can't see what I'm doing wrong :(

Note : I didn't want to post my code in case it spoiled the problem for someone else, but if it's needed you can PM me.

TIA !

pills
User avatar
hk
Administrator
Posts: 11286
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 125... what am I doing wrong ?

Post by hk »

You should check for any duplicates.
(BTW i snipped away your answer for 10^8)
Image
pills
Posts: 4
Joined: Tue Aug 26, 2008 9:16 am

Re: Problem 125... what am I doing wrong ?

Post by pills »

And here it is... D'OH !

Many thanks hk !
User avatar
Sunhill
Posts: 9
Joined: Tue Apr 29, 2008 10:36 am
Location: Sydney, Australia
Contact:

Re: Problem 125

Post by Sunhill »

Similar problem here. I've reworked my programme a few times. Struggled with the number of consecutive squares part for a little while, then had a moment of enlightening. The 11 palindromes mentioned in the example are up with no problems. But for 10^8 I got the "Sorry" page too. Taking advice already offered here, I've verified that there are no duplicates.

Here are my results so far:
Expand
Upper limit 10^3, 11 palindromes, Sum to 4164
Upper limit 10^4, 16 palindromes, Sum to 15934
Upper limit 10^5, 22 palindromes, Sum to 312690
Upper limit 10^6, 29 palindromes, Sum to 3648319
Upper limit 10^7, 34 palindromes, Sum to 29636222
Upper limit 10^9, 40 palindromes, Sum to 988022429
Any advice welcome.
Last edited by Sunhill on Fri Feb 20, 2009 11:03 pm, edited 1 time in total.
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Problem 125

Post by stijn263 »

You should've found (and removed) duplicates..
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 125

Post by daniel.is.fischer »

Your numbers are way off.
I could take a look at the code and see if there's a legitimate way to nudge you in the right direction.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
User avatar
Sunhill
Posts: 9
Joined: Tue Apr 29, 2008 10:36 am
Location: Sydney, Australia
Contact:

Re: Problem 125

Post by Sunhill »

That's shattering, yet not unexpected news.

I'll slog away myself for the time being, but may later take you up on your kind offer.
User avatar
Sunhill
Posts: 9
Joined: Tue Apr 29, 2008 10:36 am
Location: Sydney, Australia
Contact:

Re: Problem 125

Post by Sunhill »

Cracked it.

Of course, I spent most of the morning looking at the minute details of all the complicated calculations and could find no error.

Then I discovered that I had set the maximum starting integer as 31, since 322>1000. Smart move to get the result given in the example, but not much help when you want to go up to 108.

Thanks for the help.
DDgeva
Posts: 15
Joined: Mon Dec 29, 2008 12:47 pm

Problem 125

Post by DDgeva »

I'm trying to solve Problem 125 and I'm getting an incorrect answer.
It seems pretty simple and my algorithm appears to be correct. I even get correct output for the given example.

Can anyone please confirm any of these values:
For all numbers less than 10^5, the sum of the palindromic square sums is 667526.
For numbers less than 10^7, the sum is 313698021.
For numbers less than 10^10, the sum is 593978406425.

Is my program correct / close in any of these values?
harryh
Posts: 2091
Joined: Tue Aug 22, 2006 9:33 pm
Location: Thessaloniki, Greece

Re: Problem 125

Post by harryh »

@ DDgeva :

Please do not start a new topic, if one already exists for the problem you are trying to solve!

As you can see, your question was (mostly) already answered before...
in3xes
Posts: 2
Joined: Sun Oct 17, 2010 1:11 pm

Re: Problem 125

Post by in3xes »

Seems everyone is getting correct answers for 10^3, But I am getting wrong answer, I have feeling that problem may be wrong, but all 3000 people can't make the same mistake to get the correct answer. So, I should be wrong, please tell where I have gone wrong

for < 10 ^3
55 [1, 2, 3, 4, 5]
505 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
818 [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
77 [4, 5, 6]
636 [4, 5, 6, 7, 8, 9, 10, 11, 12]
595 [6, 7, 8, 9, 10, 11, 12]
181 [9, 10]
121 [11]
434 [11, 12, 13]
313 [12, 13]
545 [16, 17]
484 [22]
676 [26]
total = 5440

Everything seems to correct, I don't I can't figure out whether question is wrong or I am wrong...Help!!
harryh
Posts: 2091
Joined: Tue Aug 22, 2006 9:33 pm
Location: Thessaloniki, Greece

Re: Problem 125

Post by harryh »

Well, Problem 125 (View Problem) states :
Note that 1 = 02 + 12 has not been included as this problem is concerned with the squares of positive integers.
For the same reason, your values 121, 484 and 676 are not acceptable (they are not sums of squares of positive integers).
That leaves you with ten acceptable values (instead of eleven) and their sum is slightly less than that stated in the problem.
The value you've missed must be obvious now. Right ?
in3xes
Posts: 2
Joined: Sun Oct 17, 2010 1:11 pm

Re: Problem 125

Post by in3xes »

Thanks, that solved it :)
Junglemath
Posts: 58
Joined: Fri Sep 20, 2019 1:25 pm
Location: Minsk

Re: Problem 125

Post by Junglemath »

It didn't take too long to figure out that the palindromes that are themselves squares are not meant to be included in the sum, but you really should include a note mentioning this explicitly, or at least change the wording of the problem. A sum with a single term is still a sum. Unnecessarily sloppy wording.
Post Reply