{-# LANGUAGE LambdaCase #-}

import Data.List.Split
import Data.List
import Data.Ord

main = do
    content <- (chunksOf (25*6) <$> head) . lines <$> readFile "input"
    putStrLn $ ((++) <$> (show . day8a) <*> day8b) content

day8a xs = (*) <$> count '2' <*> count '1'
    $ minimumBy (comparing $ count '0') xs
    where count x = length . filter (==x)

day8b xs = (:) '\n' $ unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
    where img = map (head . filter (/='2')) $ transpose xs
