day3/haskell: make it more readable
This commit is contained in:
parent
eecf2c2f35
commit
793eefc817
1 changed files with 7 additions and 1 deletions
|
@ -11,7 +11,13 @@ f .: g = (f .) . g
|
||||||
infixl 8 .:
|
infixl 8 .:
|
||||||
|
|
||||||
countHits :: (Int, Int) -> [[Bool]] -> Int
|
countHits :: (Int, Int) -> [[Bool]] -> Int
|
||||||
countHits = length . filter id . map (uncurry $ flip (!!)) . catMaybes .: compose2 (zipWith mzip) (uncurry . flip $ compose2 intercalate (flip replicate empty . pred) (fmap pure . map pure . enumFromThen 0)) (map pure)
|
countHits = length . filterMap lookup . catMaybes .: compose2 (zipWith mzip) maybeIndices justLines
|
||||||
|
where justRightSteps = map (pure . Just) . enumFromThen 0
|
||||||
|
downNothings = flip replicate Nothing . pred
|
||||||
|
maybeIndices = uncurry $ compose2 (flip intercalate) justRightSteps downNothings
|
||||||
|
justLines = map Just
|
||||||
|
lookup = uncurry $ flip (!!)
|
||||||
|
filterMap = filter id .: map
|
||||||
|
|
||||||
treeCharToBool :: Char -> Bool
|
treeCharToBool :: Char -> Bool
|
||||||
treeCharToBool = (== '#')
|
treeCharToBool = (== '#')
|
||||||
|
|
Loading…
Reference in a new issue