||[May. 18th, 2009|07:17 pm]
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.So, Problem 8 in |
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.
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?
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.
Oh, I forgot that's right. Yeah. XD And then you guys are gone for the honeymoon for a while, right? XD
This sounds like the beginning of a very twisted xkcd strip...
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.
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
2009-05-19 05:41 am (UTC)
Re: Which means I have to ask
That is correct! Well done.
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. *_*;
Glad you're rocking it now, did my one-liner email help?
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.
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.
I've been meaning to get back on IRC sometime. Maybe after the wedding...
Okay, you'll have to explain to me the difference between consecutive integers and consecutive digits.
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.