[Haskell-beginners] eve / did = 0.talktalktalk...

Ozgur Akgun ozgurakgun at gmail.com
Thu Apr 22 15:07:55 EDT 2010


may not help with the parallelization desire but if you change the check
from eve/did=.talktalktalk to eve/did=talk/9999 and then to
eve*9999=did*talk it becomes lightning fast.

I tried and I can solve it in under a second now. if you want I can share
the code of course.

On 22 April 2010 18:05, Alexander.Vladislav.Popov <
alexander.vladislav.popov at gmail.com> wrote:

> Excuse me for repetition, but I first time at beginners at haskell.org and
> very first time when I sent the message I was not registered, so now I
> forward it as rightful member. I must clarify the problem a little. The
> solution I represent below is using only 1 processor from 2 of available but
> I suspect that using `par` can help to load my computer in full. So :
>
> ---------- Forwarded message ----------
> From: Alexander.Vladislav.Popov <alexander.vladislav.popov at gmail.com>
> Date: 2010/4/22
> Subject: eve / did = 0.talktalktalk...
> To: beginners at haskell.org
>
>
> Dear Everebody.
>
> Hepl me please to parallelize (parallel computing of evedidtalk
> function) the rebus:
>
> -- | eve / did = 0.talktalktalk...
>
> ten :: Integral a => [a]
> ten = [0..9]
>
> infixr 7 /:
>
> (/:) :: (Integral a) => [a] -> [a] -> [a]
> (/:) [] _ = [0]
> (/:) _ [] = []
> (/:) x y = coldiv (getInteger x) (getInteger y)
>
> getInteger :: (Num a) => [a] -> a
> getInteger = foldl ((+) . (*10)) 0
>
> coldiv :: (Integral a) => a -> a -> [a]
> coldiv a b = q : if r == 0
>                  then []
>                  else coldiv (r * 10) b
>              where
>                (q, r) = a `quotRem` b
>
> evedidtalk = [ ([e, v, e], [d, i, d], [t, a, l, k]) |
>             e <- ten,
>             v <- ten, v /= e,
>             d <- ten, d /= e, d /= v,
>             i <- ten, i /= e, i /= v, i /= d,
>             t <- ten, t /= e, t /= v, t /= d, t /= i,
>             a <- ten, a /= e, a /= v, a /= d, a /= i, a /= t,
>             l <- ten, l /= e, l /= v, l /= d, l /= i, l /= t, l /= a,
>             k <- ten, k /= e, k /= v, k /= d, k /= i, k /= t, k /= a, k /=
> l,
>             take 9 ([e, v, e] /: [d, i, d]) == [0, t, a, l, k, t, a, l, k]
>           ]
>
> Sincerely, Alexander
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100422/f373485f/attachment.html


More information about the Beginners mailing list