This commit is contained in:
thornAvery 2021-12-14 03:19:18 +00:00
parent cec5485fda
commit 9bbd9d8088

View file

@ -9,10 +9,6 @@ main = do
putStrLn $ "day7a: " ++ (show $ solveA input) putStrLn $ "day7a: " ++ (show $ solveA input)
putStrLn $ "day7b: " ++ (show $ solveB input) putStrLn $ "day7b: " ++ (show $ solveB input)
repCom :: String -> String
repCom = map f
where f c = if c == ',' then ' ' else c
solveA :: [Int] -> Int solveA :: [Int] -> Int
solveA is = minimum $ map f us solveA is = minimum $ map f us
where where
@ -32,3 +28,8 @@ absdiff x y = abs (x - y)
expdiff :: Int -> Int -> Int expdiff :: Int -> Int -> Int
expdiff x y = sum $ take (absdiff x y) [1..] expdiff x y = sum $ take (absdiff x y) [1..]
repCom :: String -> String
repCom = map f
where f c = if c == ',' then ' ' else c