Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View 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

View 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