Day 8: Golf some more
This is a terrible idea but let’s do it anyway Refer to previous commits for readable code
This commit is contained in:
parent
53d5029377
commit
000d745174
|
@ -6,12 +6,11 @@ import Data.Ord
|
|||
|
||||
main = do
|
||||
content <- (chunksOf (25*6) <$> head) . lines <$> readFile "input"
|
||||
print (day8a content)
|
||||
putStrLn (day8b content)
|
||||
putStrLn $ ((++) <$> (show . day8a) <*> day8b) content
|
||||
|
||||
day8a xs = (*) <$> count '2' <*> count '1'
|
||||
$ minimumBy (comparing $ count '0') xs
|
||||
where count x = length . filter (==x)
|
||||
|
||||
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
|
||||
day8b xs = (:) '\n' $ unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
|
||||
where img = map (head . filter (/='2')) $ transpose xs
|
||||
|
|
Loading…
Reference in New Issue