5 import qualified Data.Text.IO as TIO
13 text <- TIO.readFile "data/advent21.txt"
14 let mem = parseMachineMemory text
15 let machine = makeMachine mem
16 putStrLn $ part1 machine
17 putStrLn $ part2 machine
19 part1Code :: [Integer]
20 part1Code = map (fromIntegral . ord) $ concatMap (++ "\n")
29 part2Code :: [Integer]
30 part2Code = map (fromIntegral . ord) $ concatMap (++ "\n")
44 part1 machine = drawOutput output
45 where (_, _, output) = runMachine part1Code machine
47 part2 machine = drawOutput output
48 where (_, _, output) = runMachine part2Code machine
50 drawOutput cs = t ++ n
51 where t = map (chr . fromIntegral) $ filter (<= 128) cs
52 n = show (filter ( > 128) cs)