Page 1 of 6
Problem 008
Posted: Thu Apr 03, 2008 7:04 am
by WyldOne
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
(Link to problem added by moderator:
Problem 8 (
View Problem))
Re: probem 8 - can't post
Posted: Thu Apr 03, 2008 7:36 am
by Georg
WyldOne wrote:I get several errors when I try to post anything to the problem 8 topic.
I can confirm this.
Re: probem 8 - can't post
Posted: Thu Apr 03, 2008 9:41 am
by hk
When I type n't there the code keeps inserting backslashes. (escape characters)
Problem seems resolved.
Re: probem 8 - can't post
Posted: Thu Apr 03, 2008 9:47 am
by euler
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".
Re: probem 8 - can't post
Posted: Sat Apr 12, 2008 7:29 am
by mmstud
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.
Re: probem 8 - can't post
Posted: Sat Apr 12, 2008 9:13 am
by Tommy137
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.
Re: probem 8 - can't post
Posted: Sat Apr 12, 2008 12:28 pm
by mmstud
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.
Re: Problem 008
Posted: Sat Jan 31, 2009 8:22 pm
by ryanham
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]
Re: Problem 008
Posted: Sat Jan 31, 2009 9:36 pm
by xan
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.
Re: Problem 008
Posted: Thu Nov 25, 2010 1:00 am
by iratelyblank
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

Re: Problem 008
Posted: Wed Feb 16, 2011 10:21 am
by Darren_Zeng
99890 isn't the right answer,Why? What's the real mean of this problem?
Re: Problem 008
Posted: Wed Feb 16, 2011 6:47 pm
by jaap
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.
Re: Problem 008
Posted: Thu Feb 17, 2011 2:12 am
by Darren_Zeng
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!
Re: Problem 008
Posted: Mon May 30, 2011 2:41 pm
by godprobe
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.
Re: Problem 008
Posted: Mon May 30, 2011 8:02 pm
by hk
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.
Re: Problem 008
Posted: Sun Jun 05, 2011 8:40 am
by RickRussellTX
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
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.
Re: Problem 008
Posted: Sun Jun 05, 2011 9:36 am
by TripleM
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

)
Re: Problem 008
Posted: Sat Aug 20, 2011 8:11 pm
by jason.mond
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.
Re: Problem 008
Posted: Thu Aug 25, 2011 1:18 am
by vulcant
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?
Re: Problem 008
Posted: Thu Aug 25, 2011 6:00 pm
by thundre
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.