Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,18 @@
import Data.Bifunctor (first)
import Data.List (mapAccumL)
import Data.Tuple (swap)
roman :: Int -> String
roman =
romanFromInt $
zip
[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
(words "M CM D CD C XC L XL X IX V IV I")
romanFromInt :: [(Int, String)] -> Int -> String
romanFromInt nks n = concat . snd $ mapAccumL go n nks
where
go a (v, s) = swap $ first ((>> s) . enumFromTo 1) $ quotRem a v
main :: IO ()
main = (putStrLn . unlines) (roman <$> [1666, 1990, 2008, 2016, 2018])