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

Alexander.Vladislav.Popov alexander.vladislav.popov at gmail.com
Thu Apr 22 13:05:39 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100422/e42bbd82/attachment.html


More information about the Beginners mailing list