Day 10: Make it less incomprehensible?
I hope, at least Lambdas are a bit easier to read I think
This commit is contained in:
parent
edc4c375ef
commit
13ecd8bad7
|
@ -9,11 +9,9 @@ main = do
|
||||||
(product . map (arrangements . sum) . filter (elem 1) . group . jolts) input
|
(product . map (arrangements . sum) . filter (elem 1) . group . jolts) input
|
||||||
|
|
||||||
arrangements :: Int -> Int
|
arrangements :: Int -> Int
|
||||||
arrangements n =
|
arrangements =
|
||||||
length $
|
(\x -> length . filter (== x)) <*>
|
||||||
filter (== n) $ map sum $ nub $ map (filter (/= 0)) $ replicateM n [0 .. 3]
|
(map sum . nub . map (filter (/= 0)) . flip replicateM [0 .. 3])
|
||||||
|
|
||||||
jolts :: [Int] -> [Int]
|
jolts :: [Int] -> [Int]
|
||||||
jolts =
|
jolts = ap (zipWith subtract) tail . (\x -> 0 : x ++ [last x + 3]) . sort
|
||||||
ap (zipWith subtract) tail .
|
|
||||||
ap (++) (flip (:) [] . (+ 3) . last) . (:) 0 . sort
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user