Page 3 of 5
Re: Problem 004
Posted: Thu May 12, 2011 1:37 pm
by Francky
I've found a great trick to limitate the search in special triangle, once a candidate is found.
Who's interrested ?
Problem 004 C#
Posted: Fri Jun 10, 2011 9:59 am
by Comfyasabadger
Is there a forum for code discussion for people that have solved the problems?
Using C# for the problems and as I've got a lot to learn was looking for feed back and efficiency suggestions.
Re: Problem 004
Posted: Fri Jun 10, 2011 10:44 am
by hk
For every problem there is a forum when you solved the problem. However the forums for the lower numbered forums are locked and read only. (Otherwise there would be thousands and thousands of posts to wade through).
The idea is that you read that forum to find out if you can improve on your algoritm.
Also for the lower numbered problems there is a pdf available where you can read more about the problem.
That is the pdf icon to the right of the green tick that indicates that you solved the problem.
Re: Problem 004
Posted: Fri Jun 10, 2011 11:43 am
by Comfyasabadger
Thanks hk that makes sense.
Had better get cracking on the rest

Re: Problem 004
Posted: Sun Jul 03, 2011 12:07 am
by MarekDudek
I have better solution that one mentioned in overview.
One that never checks two numbers that were previously checked and that guarantees that first palindrome found is largest.
Thread is locked, I cannot post it. What to do?
Re: Problem 004
Posted: Sun Jul 03, 2011 12:10 am
by MarekDudek
(... continuing:)
Java code, takes below 4 miliseconds to complete
Re: Problem 004
Posted: Sun Jul 03, 2011 12:10 am
by MarekDudek
(... continuing:)
Java code, takes below 4 miliseconds to complete
Re: Problem 004
Posted: Sun Jul 03, 2011 9:49 am
by Francky
My (uncompiled) python code is under 3ms, and I can find for n=9 instead of n=3. (9×9 digits -> 18-digits palindromic number)
See previous posts.
EDIT : I'd optimized it a little.
0.26ms for n=3 (original problem)
112ms for n=9
EDIT : One more optimization (for high numbers)
0.28ms for n=3 (original problem)
33ms for n=9
and for n=11, wich is a much much harder problem, we can proove in 3.5 second
that 99999581723 × 99999321213 = 9999890293883920989999
is the biggest palindromic number, product of two 11-digit numbers.
Who can give the answer for n=13 ? (I need 2 minutes to proove the answer given after 52s)
------
EDIT : my second algo is wrong.
LucyHedgeHog found better and faster !!! (see forum after solving problem)
Re: Problem 004
Posted: Fri Jul 08, 2011 6:00 am
by ehicks
My code works perfectly for two digits, and I get what seems to be a valid answer for multiplying two 3 digit numbers. My family members got the same answer using multiple algorithms and multiple programs (Matlab and Exel). But the website keeps rejecting it. Is it possible the website is wrong?
Re: Problem 004
Posted: Fri Jul 08, 2011 6:22 am
by jaap
ehicks wrote:Is it possible the website is wrong?
No.
Does your program stop at the first palindrome it finds? Think about whether it could be possible to get a larger palindrome using a number your program hasn't tested.
Re: Problem 004
Posted: Fri Jul 08, 2011 7:16 am
by ehicks
My program starts from the largest possible value (999*999) and looks backward for palindromes. I'm just frustrated because I found the same result with multiple approaches algorithms (but all starting from the greatest). Do you have any idea what could've gone wrong? Maybe when I turn each number into a string so that I can flip it and compare it to itself, the program misses some? I don't see why that would happen... Any ideas?
Re: Problem 004
Posted: Fri Jul 08, 2011 7:33 am
by jaap
Does your program stop at the first palindrome it finds? Don't do that.
Re: Problem 004
Posted: Fri Jul 08, 2011 8:58 am
by Francky
jaap wrote:Does your program stop at the first palindrome it finds? Don't do that.
+1, but with a clever test, you'll could stop few steps later.
(it was my first algo, now I found a new way, much faster)
Re: Problem 004
Posted: Sat Jul 09, 2011 12:11 am
by ehicks
jaap wrote:Does your program stop at the first palindrome it finds? Don't do that.
THANK YOU!!! I didn't even realize the way I set up my loop it DID stop after finding the first one NOT the largest one, woops

Problem 004
Posted: Fri Jul 29, 2011 6:17 am
by jey1234
I am new to programming. I tried to solve #4 with python. But the solution is not right. Any ideas? Thanks..
from sets import Set
snip
Re: Problem 004
Posted: Wed Aug 03, 2011 11:38 pm
by thundre
jey1234 wrote:I am new to programming. I tried to solve #4 with python. But the solution is not right. Any ideas? Thanks..
New to this site too? At the top of the page it says in big dancing letters "don't post any code fragments or results."
It looks like you're making a list of all products of 3-digit numbers and then printing it out, or maybe just printing out the first one -- sorry I don't know python -- 101*101 = 10201? That happens to be a palindrome but not the largest.
Largest Palindrome of two digit numbers
Posted: Wed Sep 21, 2011 12:52 pm
by Srija
HI everyone i am trying to solve problem4 in c++
the below program is to find the palindrome of the product of 2 digit numbers(up to 10*11 for trails).
snip
the above code works for all that i need except for the largest palindrome.
my algorithm is like
1. Product each combination
2. use palindrome function to check the result is palindrome or not if multiplication res is >10 and print the palindrome.
3.here i have to check for the largest number by comparing with the previous number. so i have stored the previous value in res1 variable. and i am comparing the res and res1 variables
according to my logic it checks lastly (88<99) that is true
now the problem is how to print the last vale stored in res variable????
if anybody helps i would be thankful
Re: Largest Palindrome of two digit numbers
Posted: Thu Sep 22, 2011 1:05 am
by rayfil
Although you are new to this forum, the red banner should have been sufficiently apparent for you to notice.
This forum is not designed to post code but primarily to inquire about potential misunderstanding of problem descriptions. Posts related to specific problem numbers should be made in the related thread. For ease of searching, problem numbers below 100 are padded with leading 0's to get 3 digits. In your case, it would be Problem 004. Your post has thus been transferred to the proper thread. You may find some useful info in that thread.
Re: Problem 004
Posted: Wed Nov 02, 2011 12:22 pm
by Genemos
I am a bit stuck on this problem, I use C++ to program but I think the problem I have is that I have no idea how to describe/check if a number is an palindrome or not. I try to "learn as I go" and I realise that I do not yet know that much, but I feel entierly stuck on this problem, I don't have much of a clue on how to do it.
The problem that I am trying to figure out is that I feel I have to split the number up in order to "rearrange" it, to then check if it is an palindrome or not. Also a bit unsure on how the algorithm should work but think I can work my way around that.
Any tips to sort of get me going?
Re: Problem 004
Posted: Wed Nov 02, 2011 12:51 pm
by hk
Just a remark. The problem is about palindromic numbers, while you are talking about anagrams.