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.
logicdude7
Posts: 1
Joined: Sat Jul 12, 2014 6:20 pm

Re: Problem 008

Post by logicdude7 » Sat Jul 12, 2014 6:30 pm

@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 5:28 pm

Problem 8 - incorrect answer

Post by Julie4435637 » Mon Jul 21, 2014 5:40 pm

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

Post by paulwise3 » Tue Jul 22, 2014 8:50 am

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 5:28 pm

Re: Problem 008

Post by Julie4435637 » Tue Jul 22, 2014 12:50 pm

Thank you Paulwise3 :D - 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 8:15 am

Re: Problem 008

Post by dan7es » Tue Jul 22, 2014 2:28 pm

@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: Sun Jul 06, 2014 11:31 pm

Re: Problem 008

Post by quantheory » Wed Jul 23, 2014 2:40 am

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

Post by msc920 » Tue Jul 29, 2014 2:26 pm

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

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

User avatar
mpiotte
Administrator
Posts: 1914
Joined: Tue May 08, 2012 4:40 pm
Location: Montréal, Canada

Re: Problem 008

Post by mpiotte » Tue Jul 29, 2014 11:06 pm

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

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

Re: Problem 008

Post by Avin » Mon Aug 04, 2014 8:41 am

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

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

Re: Problem 008

Post by bazan » Mon Aug 11, 2014 9:59 pm

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 1:51 am

Problem 008

Post by elguybrush » Sun Aug 24, 2014 1:56 am

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 2:38 pm

Re: Problem 008

Post by Dyscalculia » Sun Aug 24, 2014 7:31 am

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 7:11 am

Re: Problem 008

Post by voqk » Sun Aug 24, 2014 8:41 am

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 1:51 am

Re: Problem 008

Post by elguybrush » Sun Aug 24, 2014 8:38 pm

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 3:37 pm

Re: Problem 008

Post by pkjai » Mon Sep 22, 2014 3:40 pm

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!

User avatar
mpiotte
Administrator
Posts: 1914
Joined: Tue May 08, 2012 4:40 pm
Location: Montréal, Canada

Re: Problem 008

Post by mpiotte » Mon Sep 22, 2014 4:00 pm

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

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

Re: Problem 008

Post by pkjai » Wed Sep 24, 2014 12:39 pm

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

Post by alteisen » Fri Dec 12, 2014 3:40 am

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)

User avatar
rayfil
Administrator
Posts: 1400
Joined: Sun Mar 26, 2006 4:30 am
Location: Ontario, Canada
Contact:

Re: Problem 008

Post by rayfil » Fri Dec 12, 2014 4:31 pm

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

Post by aloft » Fri Feb 13, 2015 2:31 am

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!

Post Reply