## 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

Don't post any spoilers
logicdude7
Posts: 1
Joined: Sat Jul 12, 2014 7:20 pm

### Re: Problem 008

@randomShort: Same issue was occurring in my code. NON-PROBLEM-SPOILING-HELP: 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!

Julie4435637
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 re-checked 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

paulwise3
Posts: 6
Joined: Tue Mar 25, 2014 4:35 pm

### 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.

Julie4435637
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

dan7es
Posts: 2
Joined: Thu May 22, 2014 9:15 am

### 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.

quantheory
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.

msc920
Posts: 3
Joined: Fri Jan 06, 2012 1:04 pm

### Re: Problem 008

Hi everyone,
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 1000-digit number."

but now it is, "Find the thirteen adjacent digits in the 1000-digit number that have the greatest product."

mpiotte
Posts: 1914
Joined: Tue May 08, 2012 5:40 pm

### Re: Problem 008

msc920 wrote:Hi everyone,
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 1000-digit number."

but now it is, "Find the thirteen adjacent digits in the 1000-digit number that have the greatest product."
You are correct. This question changed recently.

Avin
Posts: 1
Joined: Fri Aug 01, 2014 4:31 pm

### Re: Problem 008

I've no idea about how to ensure the sub array length is 13……

bazan
Posts: 1
Joined: Mon Aug 11, 2014 10:55 pm

### Re: Problem 008

asantosbc wrote:Could you please verify problem 8? It reads: "The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832". However, 5832 is not in the 1000 digit number.
5832 is the product of "9 x 9 x 8 x 9" those numbers are in the 1000-digit number

elguybrush
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.

Dyscalculia
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.

voqk
Posts: 1
Joined: Sun Aug 24, 2014 8:11 am

### Re: Problem 008

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.
@elguybrush I can confirm that PE is accepting the correct answer for the product of 13 consecutive digits.

elguybrush
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!

pkjai
Posts: 2
Joined: Mon Sep 22, 2014 4:37 pm

### 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!

mpiotte
Posts: 1914
Joined: Tue May 08, 2012 5:40 pm

### Re: Problem 008

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!
To debug your code, create a test 1000-digit number composed of all 9s (999999....999999). Make sure your code finds 913=2541865828329. This simple test finds many of the frequent bugs.

pkjai
Posts: 2
Joined: Mon Sep 22, 2014 4:37 pm

### Re: Problem 008

mpiotte wrote:
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!
To debug your code, create a test 1000-digit number composed of all 9s (999999....999999). Make sure your code finds 913=2541865828329. This simple test finds many of the frequent bugs.
thanks ill give it a shot

alteisen
Posts: 1
Joined: Fri Dec 12, 2014 3:33 am

### 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

abc
def
ghi

rayfil
Posts: 1405
Joined: Sun Mar 26, 2006 5:30 am
Contact:

### Re: Problem 008

abc
def
ghi
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, aei, adg, beh, ceg,cfi, def and ghi.
When you assume something, you risk being wrong half the time.

aloft
Posts: 1
Joined: Fri Feb 13, 2015 2:25 am
Location: United States

### Re: Problem 008

logicdude7 wrote:@randomShort: Same issue was occurring in my code. NON-PROBLEM-SPOILING-HELP: 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!
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!