day3/haskell: make it more readable
This commit is contained in:
parent
faaaaec0ff
commit
c5aa52cb73
1 changed files with 7 additions and 1 deletions
|
@ -11,7 +11,13 @@ f .: g = (f .) . g
|
|||
infixl 8 .:
|
||||
|
||||
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 = (== '#')
|
||||
|
|
Loading…
Reference in a new issue