Right, your program is 2 times faster than mine on my machine... I
wonder if there is a better structure to do this bookkeeping than
IntSet (maybe Sequence slightly remanied ?), anyway it goes to show
how sometimes the bookkeeping can be more expensive than the
operations it's meant to prevent !
A
I played around with this for a while based on the same sort of
algorithm and ended up with a similar solution too. It turns out the
operations saved by keeping track of already visited nodes are more
than outweighed by the cost of doing so. (As you can see, I still
have the hook in my code
2007/8/30, Chaddaï Fouché <[EMAIL PROTECTED]>:
> I managed it in 7 seconds (on 1500 MHz) with an idea close to yours
> (but I used IntSet, not IntMap), Daniel Fisher gave you some good
> ideas to achieve it, the real snail in this problem is the sumDivisors
> function.
>
I put my final solution on
I managed it in 7 seconds (on 1500 MHz) with an idea close to yours
(but I used IntSet, not IntMap), Daniel Fisher gave you some good
ideas to achieve it, the real snail in this problem is the sumDivisors
function.
--
Jedaï
___
Haskell-Cafe mailing list
The algorithm I would use:
Treat the problem as a directed graph of 1 million vertices where each
vertex has at most 1 outgoing edge. Each vertex is labeled with a
number N(v).
For each vertex v, if sum(divisors(N(v))) <= 1 million, that vertex has an
outgoing edge to vertex v', where N(v') == s
Am Donnerstag, 30. August 2007 01:08 schrieb Brent Yorgey:
> Hi David,
>
> Project Euler is a good way to learn some Haskell, although it does tend to
> give you a crash course in understanding laziness, efficiency and such in
> Haskell (whether that's good or bad depends on your point of view!).
>
Am Mittwoch, 29. August 2007 23:12 schrieb David Frey:
> Hello Haskellers,
>
> I have been trying to learn a bit about Haskell by solving Project Euler
> problems.
Good :)
> For those of you who don't know what Project Euler is, see
> http://projecteuler.net
>
> After solving problem 21, which i
On 8/29/07, David Frey <[EMAIL PROTECTED]> wrote:
>
> Hello Haskellers,
>
> I have been trying to learn a bit about Haskell by solving Project Euler
> problems. For those of you who don't know what Project Euler is, see
> http://projecteuler.net
>
> After solving problem 21, which is related to am
Hello Haskellers,
I have been trying to learn a bit about Haskell by solving Project Euler
problems. For those of you who don't know what Project Euler is, see
http://projecteuler.net
After solving problem 21, which is related to amicable pairs, I decided
to attempt problem 95 since it is an ext