[Haskell-beginners] Project Euler #01 on HackerRank, Performance issue‏

Jean Lopes hawu.bnu at gmail.com
Wed Jan 28 10:23:10 UTC 2015

@Arjun Comar: I would like this walkthrough!

2015-01-27 22:37 GMT-03:00 Brandon Allbery <allbery.b at gmail.com>:

> On Tue, Jan 27, 2015 at 8:33 PM, Jean Lopes <hawu.bnu at gmail.com> wrote:
>> Just to illustrate what I am saying: for instance this function
>> > sum [3,6..9999999]
>> Takes ~1 second to return, and these are just the multiples of 3, to get
>> the real answer I would have to first sum the multiples of 5 and 15...
> Yes, and what people are telling you is how to do this without generating
> and iterating through the list, just using the description of it. This is
> the key to Euler problems; you're using the brute force solution, not the
> math that lets you skip the slow part and get the answer immediately.
> (I've been keeping quiet because I'm not very good at this kind of math
> myself; I just recognize that Euler problems are always looking for it and
> that almost any time you find yourself iterating through a generated list
> of numbers, you're doing it wrong. Even in the cases where you *do* need to
> do so, there's usually some math that will cut the search space down
> considerably; you'll run into this if you do one of the Euler problems
> involving prime numbers, most likely.)
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20150128/b41074a2/attachment-0001.html>

More information about the Beginners mailing list