Problem 008

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.
WyldOne
Posts: 1
Joined: Thu Apr 03, 2008 6:00 am

Problem 008

Post by WyldOne » Thu Apr 03, 2008 6:04 am

I get several errors when I try to post anything to the problem 8 topic.


So I can't show you my new whiz bang cool code :D

(Link to problem added by moderator: Problem 8 (View Problem))

User avatar
Georg
Posts: 157
Joined: Mon Jan 21, 2008 7:00 am
Location: Mannheim, Germany
Contact:

Re: probem 8 - can't post

Post by Georg » Thu Apr 03, 2008 6:36 am

WyldOne wrote:I get several errors when I try to post anything to the problem 8 topic.
I can confirm this.

User avatar
hk
Administrator
Posts: 10403
Joined: Sun Mar 26, 2006 9:34 am
Location: Haren, Netherlands

Re: probem 8 - can't post

Post by hk » Thu Apr 03, 2008 8:41 am

When I type n't there the code keeps inserting backslashes. (escape characters)

Problem seems resolved.
Image

User avatar
euler
Administrator
Posts: 3068
Joined: Sun Mar 05, 2006 4:49 pm
Location: Cheshire, England
Contact:

Re: probem 8 - can't post

Post by euler » Thu Apr 03, 2008 8:47 am

I've fixed both bugs, but I'm not certain why the main problem is happening. I switched to PHP5 last night and by switching back to the PHP4 seems to have fixed it. If anyone could explain why I would love to know. The posts were being entered into the database but it was writing the cached files that was causing the error: "fopen ... failed to open stream: Permission denied".
Image
impudens simia et macrologus profundus fabulae

mmstud
Posts: 2
Joined: Sat Apr 12, 2008 6:24 am

Re: probem 8 - can't post

Post by mmstud » Sat Apr 12, 2008 6:29 am

Is it possible someone clarify the problem 8 wording and definition, 'cause i think i have not understood it correctly.

What is the "greatest product of five consecutive digits" in this example: 29384293852611. I've tried to find 93852 and 9*3*8*5*2 and 9+3+8+5+2, but none of these work for accepted solution.

Thanks.

User avatar
Tommy137
Posts: 238
Joined: Sun Feb 24, 2008 6:02 pm
Location: Cologne, Germany
Contact:

Re: probem 8 - can't post

Post by Tommy137 » Sat Apr 12, 2008 8:13 am

The solution is the product of these 5 consecutive digits. If we call the digits a1 to a1000, we search for the highest value of an*an+1*an+2*an+3*an+4 (n=1,...,996) and this product has to be entered.
Image

mmstud
Posts: 2
Joined: Sat Apr 12, 2008 6:24 am

Re: probem 8 - can't post

Post by mmstud » Sat Apr 12, 2008 11:28 am

Tommy, you made sure, im on correct path. Then i re-checked code and found there was a char to integer conversion problem, that caused incorrect answers. Thanks.

ryanham
Posts: 1
Joined: Sat Jan 31, 2009 8:18 pm

Re: Problem 008

Post by ryanham » Sat Jan 31, 2009 8:22 pm

I would be interested in writing an official PDF answer to this question since the answers in the forum posts are not optimal. Rough overview follows but if you would consider letting me write the PDF I would write a pproper draft.

Basic explaination of increasingly better methods:

[snip]

User avatar
xan
Posts: 621
Joined: Fri Jul 27, 2007 11:43 pm
Location: North Carolina, USA
Contact:

Re: Problem 008

Post by xan » Sat Jan 31, 2009 9:36 pm

I edited your message to remove text that could spoil it for folks who haven't solved it.

No one is working on an overview for problem 8, and you're welcome to do so. PM a team member to start the draft/review process.

iratelyblank
Posts: 1
Joined: Thu Nov 25, 2010 12:58 am

Re: Problem 008

Post by iratelyblank » Thu Nov 25, 2010 1:00 am

I had a ton of trouble with this program because of the wording. I thought "consecutive" meant 1..2..3..4..5, 3..4..5..6..7, etc. so I wrote my program to solve it that way and I was wondering why it was only picking up strings where I inserted "12345". But then I re-read it and I got it in 30 seconds :)

Darren_Zeng
Posts: 5
Joined: Wed Feb 16, 2011 9:32 am

Re: Problem 008

Post by Darren_Zeng » Wed Feb 16, 2011 10:21 am

99890 isn't the right answer,Why? What's the real mean of this problem?

User avatar
jaap
Posts: 538
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 008

Post by jaap » Wed Feb 16, 2011 6:47 pm

Darren_Zeng wrote:99890 isn't the right answer,Why? What's the real mean of this problem?
The problem asks for the product of the 5 digits.
9*9*8*9*0 = 0
Zero is not very large, and certainly not the largest product you can get from 5 consecutive digits.

Darren_Zeng
Posts: 5
Joined: Wed Feb 16, 2011 9:32 am

Re: Problem 008

Post by Darren_Zeng » Thu Feb 17, 2011 2:12 am

jaap wrote:
Darren_Zeng wrote:99890 isn't the right answer,Why? What's the real mean of this problem?
The problem asks for the product of the 5 digits.
9*9*8*9*0 = 0
Zero is not very large, and certainly not the largest product you can get from 5 consecutive digits.
I get the right answer.Thanks!

godprobe
Posts: 1
Joined: Mon May 30, 2011 1:30 pm

Re: Problem 008

Post by godprobe » Mon May 30, 2011 1:41 pm

I'd like a wording change for this one too.
In addition to the above-mentioned 1-2-3-4-5-6-7... interpretation of "consecutive digits" and the possible slight misinterpretation of "product" (though... on a math problem site...), the way I first tried to solve this was still using a "product of five consecutive digits", but it gave me a larger answer.

I didn't just test for v*w*x*y*z, but also (10*v+w)*x*y*z, etc. So not just 1*2*3*4*5, but also 12*3*4*5, 123*45, 1234*5, etc. Considering the wording, that should still qualify, but it doesn't. I had to check the forum to see what the problem actually intended.

And even in my notes before writing the program, I also made a comment to myself of another possible interpretation where the consecutive digits from the 1000-digit number, once pulled out, might be rearranged -- add that to my original misinterpretation above and the possible answer would be even further off.

In any case, thanks for the site! It's been a very nice way to check my programming chops and have many multilingual (and often more efficient/elegant) examples to compare to after solving.

User avatar
hk
Administrator
Posts: 10403
Joined: Sun Mar 26, 2006 9:34 am
Location: Haren, Netherlands

Re: Problem 008

Post by hk » Mon May 30, 2011 7:02 pm

If you'd searched Wikipedia on "digit" you would have found http://en.wikipedia.org/wiki/Digit.
The second link on that page would have brought you to this page http://en.wikipedia.org/wiki/Numerical_digit eliminating almost all of your misconceptions.
Image

RickRussellTX
Posts: 1
Joined: Sun Jun 05, 2011 7:23 am

Re: Problem 008

Post by RickRussellTX » Sun Jun 05, 2011 7:40 am

Wow, I am glad I checked this forum. I misunderstood this problem in an almost hilariously incorrect way.

The problem reads:
Find the greatest product of five consecutive digits in the 1000-digit number...
I dissected the sentence thusly:

Find: (the greatest product of five consecutive digits) in: (the 1000-digit number)

So I was looking for the numbers 1*2*3*4*5, 2*3*4*5*6, 3*4*5*6*7, as subsequences of the 1000-digit number. By the way, the product 2*3*4*5*6 is 720 and appears at position 388 :D

Is consecutive the right word here? I always thought consecutive implied ordered; 1,2,3,4,5 are consecutive; 5,6,0,1,3 are not although they appear adjacent to each other in the 1000-digit number.

Going straight to Merriam-Webster:
Definition of CONSECUTIVE
: following one after the other in order : successive
Anyway, if mathematicians routinely use the word "consecutive" to describe any elements that appear next to each other in a list, then I'll crawl back into my hole.

TripleM
Posts: 382
Joined: Fri Sep 12, 2008 2:31 am

Re: Problem 008

Post by TripleM » Sun Jun 05, 2011 8:36 am

Consecutive is referring to the positions of the digits; not the values of the digits. The 2nd, 3rd, 4th, 5th, and 6th digits in the number are consecutive digits in the number.

It is true that you could consider the digits 1, 2, 3, 4 and 5 to be consecutive digits, but I don't think that really makes as much sense with this wording. (You could also say that 5, 6, 7, 8 and 9 are consecutive digits, and they each appear in the 1000 digit number, but that's getting a bit silly :))

jason.mond
Posts: 1
Joined: Sat Aug 20, 2011 7:03 pm

Re: Problem 008

Post by jason.mond » Sat Aug 20, 2011 7:11 pm

Oh, boy. Complete reading comprehension failure on my part.

I read the problem originally as "greatest product of five consecutive NUMBERS" and took half a day coming up with a brute force solution. Go through all possible substrings, filter for those whose last three digits aren't divisible by 8, filter for those which don't sum to a multiple of 3, then for those remaining, do a brute force binary search. Turns out, in that case, the answer is 720.

Then I visited this forum, reread the problem, and discovered I need to go back to gradeschool to improve my english.

At least coming up with the brute force search method was fun. And ran quicker than I expected.

I was wondering why such a difficult problem popped up so early.

vulcant
Posts: 2
Joined: Thu Aug 25, 2011 12:05 am

Re: Problem 008

Post by vulcant » Thu Aug 25, 2011 12:18 am

I'm having trouble getting started at all here. I know that I'll be looking at an*an+1*an+2*an+3*an+4 when it comes to the digits but as far as expressing the digits, I'm lost. I was thinking of using the string class and elements in the string but I can't seem to do that. I don't want the answer to the puzzle but can someone help me store and display such a long number?

thundre
Posts: 356
Joined: Sun Mar 27, 2011 9:01 am

Re: Problem 008

Post by thundre » Thu Aug 25, 2011 5:00 pm

vulcant wrote:I'm having trouble getting started at all here. I know that I'll be looking at an*an+1*an+2*an+3*an+4 when it comes to the digits but as far as expressing the digits, I'm lost. I was thinking of using the string class and elements in the string but I can't seem to do that. I don't want the answer to the puzzle but can someone help me store and display such a long number?
You didn't say what language you're working with. Some, like C and Java, treat characters and integers somewhat interchangeably. And in ASCII, the digits are sequentially valued, so you can subtract the constant '0' to get the value. I have used statements like:

digitValue = digitArray - '0';

to get the numeric value of an individual digit.
Image

Post Reply