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

Alexander.Vladislav.Popov alexander.vladislav.popov at gmail.com
Thu Apr 22 06:12:24 EDT 2010


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/26bf2160/attachment.html


More information about the Beginners mailing list