X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent08.hs;h=7def6d1224d649bc1ce85097e151d2ff64f5a409;hb=def5eb181275889c4f50ea8411dff81bd565efb2;hp=e314b67e700bed5aa671a8ff507bee0cf537afbc;hpb=95bbeb70148b9f7578ec4e00f1efda43a5a24a9d;p=advent-of-code-16.git diff --git a/advent08.hs b/advent08.hs index e314b67..7def6d1 100644 --- a/advent08.hs +++ b/advent08.hs @@ -22,13 +22,14 @@ mkScreen w h = array ((0, 0), (h - 1, w - 1)) showScreen :: Screen -> String showScreen screen = unlines [showRow r | r <- [minRow..maxRow]] where ((minRow, minCol), (maxRow, maxCol)) = bounds screen - showCell True = '#' - showCell False = '.' + showCell True = '*' + showCell False = ' ' showRow r = [showCell (screen!(r, c)) | c <- [minCol..maxCol]] countLights :: Screen -> Int countLights screen = length $ filter (id) $ elems screen +screen0 :: Screen screen0 = mkScreen 50 6 @@ -36,7 +37,6 @@ main :: IO () main = do text <- readFile "advent08.txt" let instrs = successfulParse $ parseCommands text - -- print instrs part1 instrs part2 instrs @@ -84,6 +84,8 @@ execute (Rotate Row r n) screen = (rotateRow screen r n, 0) extractScreen :: ScState Int -> Screen extractScreen (ScState st) = fst (st screen0) + + parseCommands :: String -> Either ParseError [Command] parseCommands input = parse commandFile "(unknown)" input