[ create a new paste ] login | about

Link: http://codepad.org/y4LrYRX7    [ raw code | output | fork ]

Haskell, pasted on Sep 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
lk x xs = maybe undefined id (lookup x xs)

lf l = lk l $ zip ['a'..'z'] (cycle [8,3,7])
nf n = lk n $ zip ls (tail ls ++ [head ls])
    where ls = [0,2,9,8,7,3,6,5,1,4]

gen cs = let is = map lf cs
             fd = nf $ mod (head is + last is) 10
         in f (tail is) fd
    where f []     l = [l]
          f (a:as) l = let l' = nf (mod (l+a) 10)
                       in [l] ++ f as l'

main = print $ gen "abc"


Output:
1
[1,0,3]


Create a new paste based on this one


Comments: