sln_2023_20
Copyright(c) Eric Mertens 2023
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2023/day/20

This problem requires you to hack around inside your input file, so if this solution doesn't work on yours, you didn't get lucky and get a easier case like I did, but I assume we all got the same kind of dumb easy case as the last LCM problem this year.

>>> :{
describe :: Int -> Outcome -> String
describe n (Send src dst msg o) =
  src ++ " -" ++ (if msg then "high" else "low") ++ "-> " ++
  dst ++ "\n" ++ describe n o
describe 0 (Stall _  ) = ""
describe n (Stall net) = describe (n - 1) (sim net)
:}
>>> putStr (describe 3 (sim (snd (build (parseInput "broadcaster -> a\n%a -> inv, con\n&inv -> b\n%b -> con\n&con -> output\n")))))
button -low-> broadcaster
broadcaster -low-> a
a -high-> inv
a -high-> con
inv -low-> b
con -high-> output
b -high-> con
con -low-> output
button -low-> broadcaster
broadcaster -low-> a
a -low-> inv
a -low-> con
inv -high-> b
con -high-> output
button -low-> broadcaster
broadcaster -low-> a
a -high-> inv
a -high-> con
inv -low-> b
con -low-> output
b -low-> con
con -high-> output
button -low-> broadcaster
broadcaster -low-> a
a -low-> inv
a -low-> con
inv -high-> b
con -high-> output
Synopsis

Documentation

main :: IO () Source #

Parse the input and print both parts.

>>> :main
825167435
225514321828633