?

Log in

No account? Create an account
Whoops. - Chronicles of a Hereditary Geek [entries|archive|friends|userinfo]
Darth Paradox

[ website | Pyrlogos - a fantasy webcomic ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Whoops. [May. 18th, 2009|07:17 pm]
Darth Paradox
So, Problem 8 in Project Euler gives us a 1000-digit number, and asks us to find the largest product of five consecutive digits inside the number. I work out the math, realize that the brute-force approach starting from lists of consecutive integers would require somewhere in the range of 10^200 comparisons to verify a maximum, and start looking for a better way. I find one, then fail at implementing it.

Then I'm talking to Matt, and he points out the problem says "consecutive digits", not integers. Like, digits inside the number. As in 996 computations for the brute-force method instead of 10^200, and working with numbers with five or six digits instead of hundreds or a thousand.

I'm fantastic at math, and a pretty damn good programmer. But apparently reading comprehension is one of my weak points.
linkReply

Comments:
[User Picture]From: kaitou_marina
2009-05-19 02:39 am (UTC)
I think sometimes for people it's one or the other. Like for example, my reading comprehension is top-notch for the most part, but the minute anyone sets any numbers in front of my face, my brain shuts down.

That aside, are you guys coming to anime night this week?
(Reply) (Thread)
[User Picture]From: darthparadox
2009-05-19 02:46 am (UTC)
No, we'll be in Texas. I'm hoping we'll be able to make it to one more before the wedding, though... ...though I guess there's only one more before then anyway.
(Reply) (Parent) (Thread)
[User Picture]From: kaitou_marina
2009-05-19 03:48 am (UTC)
Oh, I forgot that's right. Yeah. XD And then you guys are gone for the honeymoon for a while, right? XD
(Reply) (Parent) (Thread)
[User Picture]From: arian1
2009-05-19 02:53 am (UTC)
This sounds like the beginning of a very twisted xkcd strip...
(Reply) (Thread)
[User Picture]From: kikiduck
2009-05-19 03:17 am (UTC)
Wow, this entire post just went way over my head. Well, except for the digit and the integer and the reading comprehension part. But the rest? WAY up there, flying past.
(Reply) (Thread)
[User Picture]From: miang.dreamwidth.org
2009-05-19 03:55 am (UTC)

Which means I have to ask

Is it [spoiler] 40824 [/spoiler]?

If not, I got nothin' except an explanation of why the PS2 tells me I am 13 hours into Star Ocean 3 despite being almost nowhere in the plot. :D
(Reply) (Thread)
[User Picture]From: darthparadox
2009-05-19 05:41 am (UTC)

Re: Which means I have to ask

That is correct! Well done.
(Reply) (Parent) (Thread)
[User Picture]From: miang.dreamwidth.org
2009-05-19 05:51 am (UTC)

Re: Which means I have to ask

*cheers*

That's a neat site. I find that my interest in a given problem is directly proportional to how readily I can envision a programmable solution to it. Good for my current job, but I think my college self would be ashamed of me. *_*;
(Reply) (Parent) (Thread)
From: yts88
2009-05-19 07:42 am (UTC)
Glad you're rocking it now, did my one-liner email help?
(Reply) (Thread)
[User Picture]From: darthparadox
2009-05-19 02:46 pm (UTC)
No, I'd actually solved it at home before I saw it this morning. Which is good - I prefer to work these things out myself. Though I appreciate the help in understanding the problem in the first place.
(Reply) (Parent) (Thread)
[User Picture]From: mcmartin
2009-05-19 10:25 pm (UTC)
I got nailed by a similar reading error, where I was trying to minimize the wrong thing and concluded that the answer was either "1" or "unprovable".

After being set straight things went much better.

The old nightstar network actually has a #projecteuler channel for exactly this kind of stuff, if you still have the IRC urges.
(Reply) (Thread)
[User Picture]From: darthparadox
2009-05-19 10:36 pm (UTC)
I've been meaning to get back on IRC sometime. Maybe after the wedding...
(Reply) (Parent) (Thread)
[User Picture]From: dumela
2009-05-22 01:53 am (UTC)
Okay, you'll have to explain to me the difference between consecutive integers and consecutive digits.
(Reply) (Thread)
[User Picture]From: darthparadox
2009-05-22 03:54 am (UTC)
It's a matter of context. If the number were, say, 12345625202789, then the largest product of five consecutive integers in the number would be 2520. Because "2520" is contained in the number, and it equals 3*4*5*6*7. On the other hand, the largest product of five consecutive digits in the number would be 4*5*6*2*5, since those are five consecutive digits in the number.

The point, I suppose, is that "digits" implies that the numbers to be multiplied are themselves in the number, as opposed to just trying to find the product in the number.
(Reply) (Parent) (Thread)