Problem 004

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.
harryh
Posts: 2091
Joined: Tue Aug 22, 2006 9:33 pm
Location: Thessaloniki, Greece

Re: Problem 004

Post by harryh »

Hi theslimzmassive,

Please do not post in this forum the answers or any spoilers for any problem; this forum is open to everyone (whether they have solved a particular problem or not), so spoilers are not allowed. As a result, I snipped the correct answer from your post.

As far as I can tell, the answer you propose (997799) is NOT the product of two three-digit numbers, so it cannot possibly be correct.

Finally, before starting a new thread (topic) in this forum, please make sure that -for the given problem- there is no previous topic on it. If a topic already exists, add your question to it.
Roxxor
Posts: 2
Joined: Sat Jul 03, 2010 1:17 pm

Problem 004

Post by Roxxor »

Hello! I am new to Project Euler.

Problem 4 reads:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.
The biggest palindrome I can find with 3 digit numbers is:

Code: Select all

999*991=990009
But the correct answer is lower than my answer and is considered to be the correct one.
How come?
harryh
Posts: 2091
Joined: Tue Aug 22, 2006 9:33 pm
Location: Thessaloniki, Greece

Re: Problem 004

Post by harryh »

A. Your answer is NOT palindromic. 990009, if read the other way round becomes 9000099.

B. Please do not start a new topic, if one exists for the same problem! (More often than not, you'll also find what you are looking for being there already...)
Rakshasa
Posts: 2
Joined: Sat Nov 06, 2010 5:50 pm

Re: Problem 004

Post by Rakshasa »

I've looked through both first few of the first and last pages of the solution thread, and none of them give any proper optimal solution. Would it be possible to temporarily unlock the thread for me to post a clean, readable and pretty damn fast example?
harryh
Posts: 2091
Joined: Tue Aug 22, 2006 9:33 pm
Location: Thessaloniki, Greece

Re: Problem 004

Post by harryh »

Have you also looked at the pdf for the problem?
If you have, and if you are absolutely certain that your method is faster than that, you can PM me your method.
We will then consider re-opening the thread.
Rakshasa
Posts: 2
Joined: Sat Nov 06, 2010 5:50 pm

Re: Problem 004

Post by Rakshasa »

harryh wrote:Have you also looked at the pdf for the problem?
If you have, and if you are absolutely certain that your method is faster than that, you can PM me your method.
We will then consider re-opening the thread.
Looked at it and yes, my solution would appear to be more optimal. PM sent.
AcousticBruce
Posts: 1
Joined: Thu Dec 16, 2010 6:56 am

Re: Problem 004

Post by AcousticBruce »

Since I cant post code. I am unsure how to ask what I did wrong.
My code seems correct to me, but it is obvious that Project Euler feels different. Im sure I have the error :)

I see that some people have the code hidden. How do I do this? Or better yet should I do that?

I am a Java programmer. Can you help me? How do I show someone the code to see what I did wrong?
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 004

Post by Lord_Farin »

You can send me a PM with your code, then I will look into it.
Image
nogo
Posts: 2
Joined: Thu Feb 03, 2011 10:38 pm

Re: Problem 004

Post by nogo »

Maybe anyone is willing to look through my code too?
It's written in Java and works well for 2-digit-numbers, for 3-digit-numbers I even have 2 solutions - depending on whether a "word" with an uneven number of characters is accepted as an palindrom or not.
However, nether of those solutions is accepted, and I cannot see where the problem is...
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 004

Post by TripleM »

Sure.
zlaw777
Posts: 3
Joined: Sat Apr 02, 2011 5:15 am

Re: Problem 004

Post by zlaw777 »

I can't figure out why I'm getting a Array Out of Bounds Exception. (Am I supposed to make my own thread? I couldn't find where to do so)

Code:
for(int i=palindromes.size()-1;i>=0;i--)
{
for(int b=divisors.size()-1;i>=0;b--)
{

temp=(Integer) palindromes.get(i);
temp2=(Integer)divisors.get(b); // This is where eclipse says the problem is
divide=(temp%temp2);
}
}
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 004

Post by jaap »

zlaw777 wrote:for(int b=divisors.size()-1;i>=0;b--)
zlaw777
Posts: 3
Joined: Sat Apr 02, 2011 5:15 am

Re: Problem 004

Post by zlaw777 »

Hahaha. Thank you so much. I was trying to figure out what was wrong for a good half hour.
User avatar
Francky
Posts: 90
Joined: Sat May 07, 2011 3:49 pm
Location: South of France

Re: Problem 004

Post by Francky »

I'm proud of my solution,
with n=9 (instead n=3), I can find in few seconds of Python
999 900 665 566 009 999 product of two 9-digits numbers, the greatest.
Interested ?
ImageEntia non sunt multiplicanda praeter necessitatem
Areadrill
Posts: 3
Joined: Wed May 11, 2011 11:39 pm

Re: Problem 004

Post by Areadrill »

K so I worked out a program and got the right answer... but when I try to submit it it tells me it's wrong!
I personally checked ALL the products from 3-digit numbers from 100*100 to 999*999. I am getting seriously annoyed by it.
I know I'm right and it tells me I'm wrong. Please help me! :S
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 004

Post by TripleM »

Which do you believe is more likely - 82195 people who have correctly solved the problem all have the same wrong answer, or you do? :)

Feel free to PM me if you want a hint as to what you've done wrong, but the first step to fixing your problem is believing you actually have one. Once you've truly done that it often becomes a lot easier to see the mistake.
User avatar
GenePeer
Posts: 112
Joined: Sat Apr 03, 2010 1:14 pm
Contact:

Re: Problem 004

Post by GenePeer »

Areadrill wrote:I personally checked ALL the products from 3-digit numbers from 100*100 to 999*999.
You personally checked over 404,550 different products??? By checking do you mean:

100*100, 101*101, 102*102, ..., 998*998, 999*999

or

100*100, 100*101, 100*102, ..., 998*999, 999*999?
Image
Areadrill
Posts: 3
Joined: Wed May 11, 2011 11:39 pm

Re: Problem 004

Post by Areadrill »

I checked them all from the last (999*999) till I found the first palindrome! Then I checked form that up to see if I had it wrong and so on... Took me a while too. :P
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 004

Post by jaap »

Areadrill wrote:I checked them all from the last (999*999) till I found the first palindrome! Then I checked form that up to see if I had it wrong and so on... Took me a while too. :P
But what if you make one of the factors a bit smaller and the other much larger, wouldn't that give a larger number that might be a palindrome too?
Areadrill
Posts: 3
Joined: Wed May 11, 2011 11:39 pm

Re: Problem 004

Post by Areadrill »

Weeeeeeeell... i didn't think of that. Lol i'm such an idiot... thanks for helping! :)
Post Reply