Problem 008
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.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
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
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.

 Posts: 1
 Joined: Sat Jul 12, 2014 7:20 pm
Re: Problem 008
@randomShort: Same issue was occurring in my code. NONPROBLEMSPOILINGHELP: Had each digit of the 1000 number stored in an array off 1000 integers, however even if you set the value of a long long equal to the product of integers the value still overflows as if the product is first stored in an int and then the long long set equal to that, kind of a hindrance of C++ I suppose. Hope this helps!

 Posts: 2
 Joined: Mon Jul 21, 2014 6:28 pm
Problem 8  incorrect answer
Hello,
I have been working on Problem 8 and came up with an answer. Everytime I submitted it  Project Euler kept coming back as an incorrect answer. I rechecked my code and logic but didn't find any problems. I then googled for the answer and it appears there may have been an earlier version of the question asking for 5 adjacent numbers. When I updated my code to look for 5 adjacent numbers as opposed to 13 and entered my answer  I go the checkmark as correct. Therefore, I believe my code is correct and Project Euler is checking against an outdated answer.
Julie
I have been working on Problem 8 and came up with an answer. Everytime I submitted it  Project Euler kept coming back as an incorrect answer. I rechecked my code and logic but didn't find any problems. I then googled for the answer and it appears there may have been an earlier version of the question asking for 5 adjacent numbers. When I updated my code to look for 5 adjacent numbers as opposed to 13 and entered my answer  I go the checkmark as correct. Therefore, I believe my code is correct and Project Euler is checking against an outdated answer.
Julie
Re: Problem 8  incorrect answer
Hi Julie, if you look at the posts for Problem 008 (instead of Problem 8), you will see similar comments.
Hopefully Euler or one of his admins will correct this soon?
Regards, Paul.
Hopefully Euler or one of his admins will correct this soon?
Regards, Paul.

 Posts: 2
 Joined: Mon Jul 21, 2014 6:28 pm
Re: Problem 008
Thank you Paulwise3  I see this is the same problem others have reported since May 2014 now that I have gone through posts for problem 008.
Does anyone know how to get Euler's attention?
Julie
Does anyone know how to get Euler's attention?
Julie
Re: Problem 008
@Julie, check your code for integer overflow and properly removed whitespace from any initial string(s). The correct solution does verify at the website, so you should seek the fault in your own code.

 Posts: 7
 Joined: Mon Jul 07, 2014 12:31 am
Re: Problem 008
Yep, I'll confirm that the problem used to ask about 5 digits, but now asks about 13, and that the correct answer for 13 currently verifies, while the old one for 5 does not.
Re: Problem 008
Hi everyone,
I want to ask sth about Problem 8,
I solved it some time ago,
Recently, while I was checking my solved questions ı realized that, that problem has been changed.
Before it has been changed, it had been like this, "Find the greatest product of five consecutive digits in the 1000digit number."
but now it is, "Find the thirteen adjacent digits in the 1000digit number that have the greatest product."
I want to ask sth about Problem 8,
I solved it some time ago,
Recently, while I was checking my solved questions ı realized that, that problem has been changed.
Before it has been changed, it had been like this, "Find the greatest product of five consecutive digits in the 1000digit number."
but now it is, "Find the thirteen adjacent digits in the 1000digit number that have the greatest product."
Re: Problem 008
You are correct. This question changed recently.msc920 wrote:Hi everyone,
I want to ask sth about Problem 8,
I solved it some time ago,
Recently, while I was checking my solved questions ı realized that, that problem has been changed.
Before it has been changed, it had been like this, "Find the greatest product of five consecutive digits in the 1000digit number."
but now it is, "Find the thirteen adjacent digits in the 1000digit number that have the greatest product."
Re: Problem 008
I've no idea about how to ensure the sub array length is 13……
Re: Problem 008
5832 is the product of "9 x 9 x 8 x 9" those numbers are in the 1000digit numberasantosbc wrote:Could you please verify problem 8? It reads: "The four adjacent digits in the 1000digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832". However, 5832 is not in the 1000 digit number.

 Posts: 2
 Joined: Sun Aug 24, 2014 2:51 am
Problem 008
Could someone recheck it after its change from product of 5 to product of 13 consecutive digits? I've tested my code with four digits and got the right answer, and also found the original answer online which matched my code for consecutive 5, yes it's cocky to think that I'm the special snowflake who has it right but the problem did change recently and my code does work fine for the four and five.
Thought it might have been a problem with calculating large numbers but checked the digits it picked for me with a calculator  not a double overflow. If someone who is sure of their code could check the 13 digits, it'd be much appreciated.
Thought it might have been a problem with calculating large numbers but checked the digits it picked for me with a calculator  not a double overflow. If someone who is sure of their code could check the 13 digits, it'd be much appreciated.

 Posts: 5
 Joined: Wed Aug 06, 2014 3:38 pm
Re: Problem 008
Check what? I've recently submitted the answer and it was correct. I had a different account some time ago when it was 5 and it was correct back then too.
Re: Problem 008
@elguybrush I can confirm that PE is accepting the correct answer for the product of 13 consecutive digits.elguybrush wrote:Could someone recheck it after its change from product of 5 to product of 13 consecutive digits? I've tested my code with four digits and got the right answer, and also found the original answer online which matched my code for consecutive 5, yes it's cocky to think that I'm the special snowflake who has it right but the problem did change recently and my code does work fine for the four and five.
Thought it might have been a problem with calculating large numbers but checked the digits it picked for me with a calculator  not a double overflow. If someone who is sure of their code could check the 13 digits, it'd be much appreciated.

 Posts: 2
 Joined: Sun Aug 24, 2014 2:51 am
Re: Problem 008
thanks @voqk, found my problem, the product multiplication was being done in int and then converted to long... thanks!
Re: Problem 008
hey
I've written a script in bash. I was able to generate the answer with 4 adjacent numbers. When I try to generate for 13 adjacent numbers, I get an answer but it is deemed wrong. Looking for some help! Thanks!
I've written a script in bash. I was able to generate the answer with 4 adjacent numbers. When I try to generate for 13 adjacent numbers, I get an answer but it is deemed wrong. Looking for some help! Thanks!
Re: Problem 008
To debug your code, create a test 1000digit number composed of all 9s (999999....999999). Make sure your code finds 9^{13}=2541865828329. This simple test finds many of the frequent bugs.pkjai wrote:hey
I've written a script in bash. I was able to generate the answer with 4 adjacent numbers. When I try to generate for 13 adjacent numbers, I get an answer but it is deemed wrong. Looking for some help! Thanks!
Re: Problem 008
thanks ill give it a shotmpiotte wrote:To debug your code, create a test 1000digit number composed of all 9s (999999....999999). Make sure your code finds 9^{13}=2541865828329. This simple test finds many of the frequent bugs.pkjai wrote:hey
I've written a script in bash. I was able to generate the answer with 4 adjacent numbers. When I try to generate for 13 adjacent numbers, I get an answer but it is deemed wrong. Looking for some help! Thanks!
Re: Problem 008
Hi. I just want to clarify something. Well, I tried to look the answer on the internet, but I don't get why the answer like that. What I mean is "13 adjacent numbers", is it the same as "13 consecutive numbers"? In my knowledge, consecutive is like this:
abcdefghi
While adjacent is like:
abc
def
ghi
(a,b,c,d,f,g,h,i is adjacent to e)
abcdefghi
While adjacent is like:
abc
def
ghi
(a,b,c,d,f,g,h,i is adjacent to e)
Re: Problem 008
But they must also be on the same line if you are looking at more than two items. Thus for three adjacent items, the only candidates would be:abc
def
ghi
abc, aei, adg, beh, ceg,cfi, def and ghi.
When you assume something, you risk being wrong half the time.
Re: Problem 008
logicdude, you fixed it for me. I had obtained the correct answer by rewriting my code and dispensing with the use of numpy and it's 'prod' method in Python 3. But I was still curious as to why my previous attempts (whose algorithms were correct) kept failing. I noticed that the wrong answer I obtained was a common one among those who had not solved the problem and most comments attributed it to integer overflow. But Python 3 shouldn't have that problem. But of course, numpy is probably written in C and DOES suffer from that. Still, initializing my product as a 'numpy.uint64' simply produced a larger but equally incorrect solution. It wasn't until I realized that in my conversion of the 'string' of digits to a list, then another conversion to a list of integers, the product would likely have been already overflowed. Converting the string list to a list of 'numpy.uint64' integers (even though they are all single digits) did the trick, and I never would have discovered why my 'old' code was broken but for your post! Thanks!logicdude7 wrote:@randomShort: Same issue was occurring in my code. NONPROBLEMSPOILINGHELP: Had each digit of the 1000 number stored in an array off 1000 integers, however even if you set the value of a long long equal to the product of integers the value still overflows as if the product is first stored in an int and then the long long set equal to that, kind of a hindrance of C++ I suppose. Hope this helps!