Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
import Data.List (delete, sort)
|
||||
|
||||
-- Functions by Reinhard Zumkeller
|
||||
ffr :: Int -> Int
|
||||
ffr n = rl !! (n - 1)
|
||||
where
|
||||
rl = 1 : fig 1 [2 ..]
|
||||
fig n (x:xs) = n_ : fig n_ (delete n_ xs)
|
||||
where
|
||||
n_ = n + x
|
||||
|
||||
ffs :: Int -> Int
|
||||
ffs n = rl !! n
|
||||
where
|
||||
rl = 2 : figDiff 1 [2 ..]
|
||||
figDiff n (x:xs) = x : figDiff n_ (delete n_ xs)
|
||||
where
|
||||
n_ = n + x
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $ ffr <$> [1 .. 10]
|
||||
let i1000 = sort (fmap ffr [1 .. 40] ++ fmap ffs [1 .. 960])
|
||||
print (i1000 == [1 .. 1000])
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import Data.List (sort)
|
||||
|
||||
r :: [Int]
|
||||
r = scanl (+) 1 s
|
||||
|
||||
s :: [Int]
|
||||
s = 2 : 4 : tail (complement (tail r))
|
||||
where
|
||||
complement = concat . interval
|
||||
interval x = zipWith (\x y -> [succ x .. pred y]) x (tail x)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStr "R: "
|
||||
print (take 10 r)
|
||||
putStr "S: "
|
||||
print (take 10 s)
|
||||
putStr "test 1000: "
|
||||
print $ [1 .. 1000] == sort (take 40 r ++ take 960 s)
|
||||
Loading…
Add table
Add a link
Reference in a new issue