Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Ludic-numbers/Haskell/ludic-numbers-1.hs
Normal file
13
Task/Ludic-numbers/Haskell/ludic-numbers-1.hs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import Data.List (unfoldr, genericSplitAt)
|
||||
|
||||
ludic :: [Integer]
|
||||
ludic = 1 : unfoldr (\xs@(x:_) -> Just (x, dropEvery x xs)) [2 ..]
|
||||
where
|
||||
dropEvery n = concatMap tail . unfoldr (Just . genericSplitAt n)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $ take 25 ludic
|
||||
(print . length) $ takeWhile (<= 1000) ludic
|
||||
print $ take 6 $ drop 1999 ludic
|
||||
-- haven't done triplets task yet
|
||||
9
Task/Ludic-numbers/Haskell/ludic-numbers-2.hs
Normal file
9
Task/Ludic-numbers/Haskell/ludic-numbers-2.hs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
ludic = 1:2 : f 3 [3..] [(4,2)] where
|
||||
f n (x:xs) yy@((i,y):ys)
|
||||
| n == i = f n (dropEvery y xs) ys
|
||||
| otherwise = x : f (1+n) xs (yy ++ [(n+x, x)])
|
||||
|
||||
dropEvery n s = a ++ dropEvery n (tail b) where
|
||||
(a,b) = splitAt (n-1) s
|
||||
|
||||
main = print $ ludic !! 10000
|
||||
Loading…
Add table
Add a link
Reference in a new issue