Page 1 of 1

Problem 125

Posted: Sun Oct 12, 2008 2:20 pm
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

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

Posted: Sun Oct 12, 2008 2:42 pm
by hk
You should check for any duplicates.
(BTW i snipped away your answer for 10^8)

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

Posted: Sun Oct 12, 2008 3:51 pm
by pills
And here it is... D'OH !

Many thanks hk !

Re: Problem 125

Posted: Fri Feb 20, 2009 10:24 pm
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.

Re: Problem 125

Posted: Fri Feb 20, 2009 10:41 pm
by stijn263
You should've found (and removed) duplicates..

Re: Problem 125

Posted: Fri Feb 20, 2009 10:44 pm
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.

Re: Problem 125

Posted: Fri Feb 20, 2009 11:11 pm
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.

Re: Problem 125

Posted: Sat Feb 21, 2009 1:14 am
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.

Problem 125

Posted: Tue Jul 20, 2010 11:12 am
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?

Re: Problem 125

Posted: Thu Jul 22, 2010 5:30 pm
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...

Re: Problem 125

Posted: Sun Oct 17, 2010 1:22 pm
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!!

Re: Problem 125

Posted: Sun Oct 17, 2010 1:43 pm
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 ?

Re: Problem 125

Posted: Sun Oct 17, 2010 1:52 pm
by in3xes
Thanks, that solved it :)

Re: Problem 125

Posted: Sun Jan 03, 2021 7:26 am
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.