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
main = do
text <- readFile "advent08.txt"
let instrs = successfulParse $ parseCommands text
- -- print instrs
part1 instrs
part2 instrs
extractScreen :: ScState Int -> Screen
extractScreen (ScState st) = fst (st screen0)
+
+
parseCommands :: String -> Either ParseError [Command]
parseCommands input = parse commandFile "(unknown)" input