From 757b98fb30e75d7698a0986184d0303224db156c Mon Sep 17 00:00:00 2001 From: Prefetch Date: Tue, 26 Mar 2024 21:41:32 +0100 Subject: Publish days 6-10 --- 09/input.txt | 1 + 09/lib.scm | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 09/main.scm | 14 ++++++++++++ 09/test.scm | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 09/input.txt create mode 100644 09/lib.scm create mode 100644 09/main.scm create mode 100644 09/test.scm (limited to '09') diff --git a/09/input.txt b/09/input.txt new file mode 100644 index 0000000..da21895 --- /dev/null +++ b/09/input.txt @@ -0,0 +1 @@ +{{},{{{{{},{{!<",!>},,<'e">},{!!a!!a!>},ue!>,<"!!!>!}>,<}!!!>,ii>}}},{},{}},{{},{{!>,},{},{<{}}!>},}},{{{{<}i<}"">},{>}},uo{}!!'!!o!>>},{!>},!>,<>,{{,<>}}}},{{{},{{}}}},{{<{u'""o>,{!!!!e{uea!>!!i>}},{!!!!e},,,<>}}},{{{{},{{{},{<}<{!>},},!!}},{},},<>}}},{,{}},{!>eie!>,"!!!,,!>,<}},<>,<>}},{{{}}},{},{{{,,}!>},<"ai>,{!!u{{!{!>},<<{o!>,}}},{{{},{<<,"!>},au!o>,'!!!>,},<'oaaou!!!!!>},!>,},{{{{{},}},{,},}},{{},{{},ie"e!>},!"i!>{!>},<>},{{{{,<}}!>},},},,<,'!>!!<,}{e>},{,<>,<}!>!!!>"!>},<'!!!>}<>}},{{!>},},<>}},{{{},{<}"a}!>,!>},,<<}{o""!!a!!,a>}},{{<>}},{{}}}},{},},!>{>},{<>,<<>}}}}}}}},{{{{},<}}'!>,}>}},{<"!!!!!>,'!!i}{o!>ai{"!!!>>,},">}},{{}},{{{{},,{<}!!!>,,}},{{,}!e>},{<}a'!,}>}}},{{{},!!u"}>},{!>,},,i,!i}'!!!!'">},{{},,,<"!>!{}a{"!!o<"'!!!>o}{a>},{},<"!{<'>}}},{{{{{},{},<>}},{{}}},{{{{{{}},{}},},{{!!ua!>oa}uia>}}}},{{,,<}"!!!!ei!!!>!>!"ii}>}}},{{{{u!!!!!>,o",!!!>!u!>,<>},!!!>!!o!>,<{,!>!>},<>}},{'>,{!>,!!}!>,,<>,{}}},{}},{{<>},{!>},o!>},},<>},{{,aa!!>},{<>}}}},{{{{},,<'!>},!!<>}},{{},,{{!!!>a!!!>!!{>},!>},!>,}}},{<'oei!>},!{e!>,,{<>,{,,!>,},<}>}}}}}},{{{{,},!!!>},<{!!!>>,{!>"ua!!!>!!,}'!!ai,e!>},}},{<>},{}},{{{{<}},{}},{<,,o!"uu",,!{'>,!!!>},<'!i!>},},}}},{{},<!!{!>}"a>}}}},{},{{{{{{,},<<>}},{{<}!!!>}!!>}},{{,{<}!!i!'eu}},{{}},{!},ii!!},<"!!!>!'o>}}},{{{},,}},{},{{},!!!>}!>,<>},},,,<}'>}},{{{},!>,},}},{{},<{!!!>!"},<"!!!!a!!e!>,e}>},{{},<>},<">}}},{{<o}>}}},{{{{{<>}},{{a'>},{,<}i}"{}!<,e>}}},{{{}},{{,!!o!!!'u{!!!>},u!,!!"i}>},{{<"!!}{u',,<{!!!>eu!!!!!>>},{{}}}},{{{{<'i!!},a!>,!>!>,,<"!>},>,{ou},!!!>"a!!o!{a!!'"}!!">}},{{<<,!!>},{{,},{!!i}'!!!>!>,,i!!!>>}}}}}}}},{{{<}uo!!!>i!!ii!>{!!o">}},{{{{,!!!>>},{}},{{<,!!>},{},{{},<"!!!>!!!>'o"o{!!e'"a>},{}}},{},<,u!>,!!!><{au}!>>,{}}}},{<{!!ee!!!>!!a!i!>ei!!e!!!!!>!!!>e!!a">}},{{{{{},{{<"o!!{>},{}}},{,,,<{,}{!<{>}}},{{{{o}i!!i!>},<}'>,{}}},{},,},},}},{}},{{{{}},<{!!},{{>}}},{{{{{,},,},!!},},{{!!e",""'a!!o}!!!>"!!!>}>}},{{},<{',{a>}}},{{{},<{i!!!!!>,<>}},<}!!!!'>},{{,<>,{},o!!"'!>,}},{{<{"!!o!!!>!!!,>}},{{}}}},{{{},{},{}},{{},{{}},{{{!>},,{<,a!!!>}oa<'ii>}}},{},{!!!>{oiu>}}},{{{{{},}!!">,{<},!>,<<}}}},{{{{{}}},{{!>},},,>}},{{},<>},},"!>!!!>!>e>}},{{{{,<<">}},{{,},<}!>,!!!>,,!>},<,!>,o>}}}},{{},,{}}},{{},{}}},{{!!!>>},{{},{,},<,{>}},{<,!!!>},},<<>,,<"a>}}},{{{<,i'"!!u}!>,<,o!!{!>,<{ou,,<'!!}>}},{{{}},{{{},!!a!!!>e>,{<,>}},{{},u!>>}}},{<"!!''"!>,,<}',!>e!>,u>},{<}}}},{{{,},,,!!!>"!>,>},{{,<"!>},,,{!i"a!e{!!>}}},{{<,,"!!o!>ei"''u>,{{<!!u!>!>!>,!'!}}}},{{{{{ea!!!!!!!>},<'!>},<>},!!,'e!>,<,}!!">}}},{{,},,},e{ie>,{{>}}},{!!i"u!!!!o!>},<}e!u{!>{u!>},<'i}>}},{,<}},{<,!>!!!>},<!!!eu!>!>},<{!!}ao"iu>,'e!>!>},},<}},{{{{,oa},{e!!!!a!!!>,,<','"a!!!!!a!u>},{{!!!>,>}},{{{{{eoi>}}},{{{!>,<>},}},{{,!!a!>},<{,}!!!>e!>>},{},!!i!!!>'a>}}},{{,!>},<}">},},'o!!!>}'!!,>}}},{{u{i}>,{',}!,ia!!i,!!!!>}},{},{}},{{{{{<"e!!!!}!!!>!>},<>}}}},{<{{,"}!'o!!a!!!>!!!!""{}!!!>>,{}}}}},{{},},{{},!>},<}!!!>!!i,!>{!>a!"{!!!>!!>},<<{!>,<"o!>,'!>o}>},{,!i,>,<}!>!!o!!!>{!!'o!!i>}}}},{{{},,{{'}{!!!!>}}},{{},!>,},<'{o"!!!!o!>o,<{,o{!!!>,},{{},{},{{,<"!!{iu"i!>euoa}!!!!},{!!u'!>,<"!!!!},}}}},{{{<>},<}'"o!!!>""!!!>},<',{},<>},{{,uao!>},<>,{{},},<,!>i!!!>o<{!e,i>,},oei!>,}},<,!!!>'!!!!{o>}},{{<'u!!!>!>},},{{{{,},,,'!!o!!u>},{}},{{<'!u!!!>"}!ui!uo!{!!!>!>,'e>}}},{},{,<<'>}},{{<{u'}'!>i!!i!!!"!!'!>},},}}!!e!>,},{<'a{o!>},<,!!>}}},{{},{{},{{},!!!>},,e!!!!!>'!!!!!>!!o!!{!!{,<>},{},<>}}},{,<}>}}},{{,<,'u'e>,{{}}},{,iae{>}}},{{{{{{<}}o!!,"{},o{!>},<"!!!>,<>}},{}}},{{{{euu!>,<>,{<,!>},!>!>},{!>},<,!!!!"!>,}},},<{!>,},<,u"!!u,!!{}ouo>},{{{{}}},{},},!!e!!{a>}}},{{},},}!!'i!>"!!e"',!!'!>>},{{{{{!ae!!"}!>},<<'!}!!'!!!>},}},<>},,>},{>},{{{{},}u>},{}},}}}}}},{{,,{o!!ie}!!>}},{}},{{{{,e!{!e,<,,<>}},{<<}!!e!!e!!''oa>}},{{{,i!>,!'>},{,<"u!>},<'},<,}},{,<}!!'!>,<>}},{{{<{!!!>}a!>},},!!!!u,<'a!>,<>}},{{},a!!'!!!>e'!!>}}}}},{{{{{{}},{<"i!>},,<"{o}"{!!a!>},<>,,!>!>},!>},{{,<,<"!!!!io{}o"e!>o!!o}{u>}}},{{{{{}},{{},},}!,"{<'{a>},{{,{<"'!,!},,},<}>}},{}}},{,,!>,!!!u>},{,<{a"euu>,{<'>}}},{<}ia!>},!>!!!>!!!!!o!!!>,">,<"u'>}},{},{{<'!>{a}!>},!o!e}!>"e!e}!!!>},<>,{},},},,<{!{e!!!!!>a!!!!!>>}},{{{,{!!!!a<>}}}}},{{}},{{{{<'!>,{{i!!i!!!>!!!!{!""},{<}{e!!,e"',{<,,},,},<'>}}},{{{}},<{"a!!!>!e>},{{{{!>,<}!>},,!!!>!>,,<}!!!{e,<>},'o!!!!a!>!>,},<>},}!!ei!!!!},},<,}},{{{},!>},<},{}},{<},},a"!!"!"!>,<'!!!>,<>,!!!>,<}!!i!!!}"!>,!!!!!>,<>}}},{{,<>,{}},{{,<,!>!!!>!!!!!ae!>},>},{{},<,',{!>,<<>},{{<'!>},,!!{<>},{{}!""a!!!>!>,!!!!!!!>>}},{{},<,'!!uu"{o!!!>"ea!!e!>},},u!>i!}}!{},},!>},<{!>,<>}}}}},{{{},u!!"!!!>}a{!!!>oie!!!u!!!>ua,!!o<>}},{{{{{},!!!>!>,<>},}},{{{}}}}}}},{{{{{{},!!!>!!a!o,}i{o!!!>!!!>,<>},},,!!!>!o,"!>euu!>!!!>!>},!>,<>},{{>},{}},{{<{>},{}}},{{{{}},{{{{},<<{i!!ao!!!>'!"e">},{{{}},{}}}},{{{<<'!!!>"!!!!!o!>},<{'oi!!o!!!>},<>},,',!{e{>},{{{<>}},{,},},i>},{,o!!!!}!!!>>,{}}},{,{!>,<,!>},i!!!>iei>}}}},{}},{{u<{e!!{e">},>}},{}},{{{{{<},},},<<}},{!!!>i!>>,{{},{<'!>,,<>}}}},{{!!!>!>,,},,iu>,{!!!!!>!au!>'>}},<>},{{},<"!o!>},<,},<,e>},{{}}}},{{{{,!>'}i!>},>,},},{{{{},},{}}},{,{<,"{!!!!,o"},!>},,!!"!!!>,>}}}},{},,<,u"!>,u>,<,!!!}!>,!"!>,<>}},{{{{!!"!!!!"!i,{<{!!o!!{!>,}},{}},{{<{e!!!!,,!!e}!e!>,,""!>},}},{{{{}},u!{>}}}},{{{{}},{{},{{},{<"!!!>!>,,<,e!,a>}},{"u<>,{},},,<>,,!!<}{!!!,"uo>}}},{}},{{{{<{"a!>},},,<,>},!!a!>,<}!!!!!>!!!!o!>,<}!!{oe!u">},{{{<{!>},o!",>},},{{<}>},<<}""a!!!>},>}}},{{,<"i!>},<>},{<'>}},{{{,!,e<!>},<o!>},!!i!>>},{<,i">}}}},{{<>},{<>}},{{{},{{{<,,,}}},{{<,}'!!!!!!'!!!>},<>,>},{<'e!>}},,{}},{{},{{,o!>aa>},{>}}}}},{{{{a!ie>},au!>"!!{!{i!!i,'{!!!>!!'>},{!!!!e>,{}}},{{}}},{<'a!o!>},<>}}},{{{!!ae!u!!,{{,<}!!u!>,,u!!e!!"!o>},,,,,<>}},{e!}'!>,<,!"u!!ou{}>}},{{{<{!!!>a'!>,},}},{<}a!!!!,!!io!{>,<}u!>!!!>i!>!eu!>},<{!!}!!!>{!!!>u>}}},{{{},{{}}},{{{{<{},,},,,}}},{},{<}!!!>}i!!}u!>,},}},{{},{},{{<>}}},{{{{,<<{i!!!>!!>},<{!>},'u"e<,!!i!">},{{},{}},{!>},<">,{,<>}}},{{{<',<,},!>>,{}}}}}}},{{{{<}e"!>{!!!>!!,a}!<>},{{,{,,<>}},{<,}>,,},<'!!'>},{>,{{!>"!>,<{ue<'}{>}}}}}},{{{{{!!ea!"!i>,{,<>}},{},{{{{,,<,,ii!u!>},<,i!>,,>}},!>,<'!!!!!>{!>,<>},{},,<""uo!!!>!>"!!aa,o!uu>,},}}!i!!"!!!!!>!!!>!>},<>},{<>}}},{{{>,},<},!>,},<<,{!,}},{},,<}}!!<>}}}},{{{<>,{{}}},{{o"u!!!!!!e!!io},<>},{{!>,<,!!!!'ei!>{>},!!!>o!>},},}},{{},<'u"e}u>},},!>,!!!>!!!>!!,o!>i!!>}},{{{e'!>},,"!>!>,<>},{},{},<}u!!!a"!>}>}},{},{{{{!!"!!'!ou!>},"uuio!u{>},<,!>,}{!ae'!!!>e}>},{{},<}!!i!i{}i!ii>}}},{{{{{},>},{{{<,u"!!!>aae!u},},<{<>}}},{{{},},}},{},<,',,,<}}},{{{{,!!!!'!>,<,!!}!!!>!>,}}},{}}}},{{{{{<,!!!>},},{<>,},<'"!>,,<>}},}},{{{{{},<'i>}}},{{},{},<'!!!>,,{}}}}},{{<',{u,>,{!>!ia!>},}},{{},{!>,!>,!!!>o,o{}o>,{<>}},{{},{{<{'!>},,}}}},{{<}!>!>},},<>}}},{{{{>,},,!>},,,},{{{,!!!>,,,,,{{},<<,!!!>e!!!>'}!}!><'>}}}}}},{{{{{{},{}},i'!!!>},<}o>},{<{!>i!>},<>,,<},<>},{{{<{!!!>}!>},<'>},{{{{},},<,}!>,}e>}},{{{{!!a'{i!>},<>}}},,aa{!>},},},,<'!!!!!<,>}},<'e!!{!>},!>,<}>}}}},{}},{,}aa}>},{{'!{,'u,!>,},,},{}}},{<}"}e}!!'!>},<,!!!>}!!}>}},{{,},{{},<<}"}},{{<"!!}},!>,},,},},},,!!e!>,<>}}},{{{{{{}},{{}}},{{},{}},{{{{>},{<,!!!!!>'!,a'!!i!"aooo>}},{<'!!!!!{au!!'!eaueuo!!i'!!!!!>{!!e>},{,<'uu!>},{!>,,<>,{}}},{{<,>}},{{<"a>},{<'!!!>"!>,,},,}i!>},},,<}{,i>},{{,},}}}},{{,,<,a!!,!>!!!>'!>},<}!>,<{ua}"o>},{{},{!}">}},{,!>,,ei!>,,,<}}},{{{{{{,<">}},{},{{{{{{}}}},{,{<"iu!<<,!>"{au>}}},{{{}}}}},{{{{{{<,u}a!>,<,!>},i!>,},<,>,!<>}}},{{!>!!!>>,{}},{{}}}},{{}}},{{{<>}},{{,<<>},},>},{}},{{!>},'>},{}},{{<}{e!>},}i!>,,!!{>,<>},{{<>},!>,">}}},{{},{{{>}}}},{{{{},<!>},},<>},{}},{{},},<>},{}},{}},{{}}}},{{{,<,!!!>!!}!!!>,<"a<},{}},{{},{{!'!>e!!!>!>},,,,>,{!!{!!e!>!}>}},<'o!}!>},!e<,,},<>}},{}},{},{{{}e!!!!io!!,}},{{{'{,!!u}>},{}}}}},{{{{}},<>},{{<{!>,iu!>,}!>},<,!>">}},{{},{{{{"!>!!!!!!>}},{<'o}u>,{<}!!i!!!>},},oo>}},{{},{{{},,<"{{>},{!!!>o,,>}}}},{{<}!>},,!!}!!!oi!!>},{{<>}}}},{{{{}}},{<"!!!>},<{>,{}}}}},{{{"!>,!!}!au!!>},{{<>},{>}},{{,,ui>},{<,!>,<'!e>}}}}},{{{{<'{}u}u!>,,e!!o!o!>},<}!>}>,{!!u!!"<,!>!>!!",{>},{{{!!!>!>e}!>,,<"!!}}ii!>!!!>}>}}},{{}}},{{{{}},{<<}>}}}},{{{{{<}!}},<>},{{{{}},{{},,{,<>}}}},!!aa!>>}}},{{<{'ia}!>},},},,{}},{{{{},<>}}},{}},{,{,}}}},{{{{<}">}}}},{{{},{{{{<,{!>{!>},},,}},},""!>,,<"e!!!>},}}},{{{!>!>!>,!!!>!>,<>},{}},{{},{{{}}}},{},,{<>}}}},{{<"!e<,i>,ia,uu>}}}}},{{{{},i!!!>!>,!>!!!>!!!!>}!>},},},{,}},{<'a">,{},<>}}}},{{{{{}},{!>"o>,<>},{{},{<>,>}}},{{},!>}}>},{{<{!!!!,'e>}}},{{<{eea'!!ui"a}},{{<',!>>}}}},{{{{<,},<}<,>}},{{{}}},{{u'!!uaa!!!>},},{{<,!>},!e!!!>!!>},{<"}!!!>"}!!!><>,{}}},{{!>,!e!!!>eu,>,{}},{{!>,<,!!'},}!!!>},}}}}},{{},{},{{},{},<"io>}}},{{{>}},{{{{},{}}},{<}oo<}!!!!i<>,{}},{}}},{{},{{i!i!oi!>o"!>,},<<'>},{{},<{u!u!>{<>}}}}},{{},{{{{{{,<{!!!>!>,},<,!'{,'}},<,>},{!{>,<<}!!!>!>,e!>},<{!!!<}!!<},>},{{},{{{}}}}}},{}},{{{{{<{!!!>>},!"<"!>},{},{}},{},{{<{'io!>},<>,{},<!oa'>}}},{{{<>,},<}{a!>,<>},{{{'!>oa!>!>},!!!>!!!>a!>,,{<,}<,"i!>,<""!>!!!!!au!!}i!!>}},{<>,},{{{,,,o!!!!>}}}},{{!!!>e}i!!!>,}}'}<>},{{},{{{<{e!>}!>,{i!>,!>},,,{}}},{{{},{<'a!!{"au!!!>!>{!<}!>!>,<{>}}},{{{<}!"!!a"e>}}}},{{},i!e!!!!!!!>>}}}},{,}o!!!!!!!>,{!>,},<},!>},}}},{{<'o<'>},<>}},{{{},{}}},{{},{{'!!ouee,},<<>}},{{{}},{oee!!!>!>!>},<'!>,}}}}},{{{{{!!!>!!u!>},<>},{<,uo!!!>a>}},{{{},},,!>,!!!!!o!,>},{}},{{},<}!>iu!!a!!'e,"">}}}},{{<'!{,}a!a'!!a!><}!i}>,{<,{aii!u!!!i>}},{},{{,},{,}}}},{{{{{{<>,{,<,i,!>,,<'{>}}},{{<"u>},{},<{!},!!e!!!>!>},<>}}},{}},{{{,},<>,{,{!!!>!!>}},{{!>,!>,<">,<"i<>}}},{{{!!!>o{>,{{<}i"i}!!i{a,<}}},{{{,!!!>!!!>{!>ia>}},<,!i,u!!!>!u!>,,<>}},{{},{},{<e},,,{>}}},{{{!!!!!!!!!!!>},<,!!!>!!>}},{<}o">,{}},{<<}""}!>,<>}},{{{<"!{'a>,{o!!!!oa!>,}},{<,!>{,ii"u,!>!!!>!!!>"o"ui!'>}},{},{{!!!>,},<>},,,>}}},{{!>ae},{}},{{{},,!oie!>!>},<'!!u'!}>,{}},{{,,a{ae<}e!!,!>},!>,<>},{,},<{a!>,},>}},{<}!>},<>,!!e!u!>'a!!!!!>a!!'>}},{{{{},,,!>,'>}},{}},{{{{<"!>,!,!>},}i,a>}},{},<>}}},{{},},}},{{{{{<'!!{!>},!,a,ia!!e!>,<'}!>,<'!!!>,<>}}},{<{e!>,},}},{{{},{},,{{{{},{<"!!!>'!>''!!!>!!{{>}},},<<,,i!>},}i>}}},<',u"o,'uou!!!>,!!!u!>,>},{<"i!!'<>}}}},{{{},<},{}},{{<>,{<>}},{"!!!>,},<,<<}!>},,{}},{!'{o!!!>},!>},<>,},}}},{{{{<>},{},<<'e>}},{{{},{{},{{}}}},},!!{{u'o!>!>},,},<},!!a}>},{},''o,,{,<<',,!!!>>,{i!>},},!>},}}}},{{{},<}>},,{!>},},{{{},{{,{{},<>},{>}}}},{{u"a"'}e!>}>,{}}}},{{<}>,},{,,!!,!!ue!>!>>}},{{<"'}"!!!>>},<<"{!>aie"!>,<"e!>>}}},{{{{{<},!!!>!!!!a!>,<>},,!>,<}}},{}},{}},{{!!}!!},e{{>,{{!>,}}},{{}},{},<'{ii>,},,<,au!},e!}!>>}},{{{},{}},{{},{}},{{},{}}}},{{{{,}}},{{<"!!!>!>,,},<'>}}},{{},{{{},<{'{,!'{<>}},{{},{<"!,!}{{{!>,<>}},{{,{}}}}},{{{{{!!oe!>,'!!!>!!!>o>},},},{<<!}>,},<}!!!}u!>},!!!>!!!>!!a!!!!!!ou!>!>,<>},{}},{}},{{}}},{{{,,},!>},>,{!>"!>!>,<}}}},{{{{<'!}}>,{}},{},{{o!!"!>!!>},},},u'!{"!>,}},{{,},!!!>!>a!>},u>}}},{{{{>,{<,a''a,!!}>}},<,},<>}},{{},{{{"o{'"{}!!!>!>},<>},{,},e!>},<}"!>!!!!!o!,{<,,a!!}!!!uiuai!!!>!!,>}}},},},{{},{{<>}}}},{},{{,!!!!i!!,>},{{{},<},<<'<>},{}}},{{,<>}}}},{{},{{<e}o>},{{{,!!u!!''>},!!}iu}>},{i,!'{au{'!!!eueu>}}},{{,{!!e>,!>}!>},e!!"!"!!!!!>!e}{>},{,o!>},<'}!>},,a<"u>},{<"{!!!>,<<>,{},},<,!!eaa',<{uo>}}}},{{{{}!>},<'!e!!"a!>!<}!>,,,>},<,<,},{{{{{}},{}},{},!>"o",u'!"!!!!>>,{!!!>'{u!>},}},{{},<'!!'!>},},!e'u,>}},{{{},{},{,}''!!!ae}!>,<"o">,!>},!>},<'!>},<},a!!!>>}}}}},{{{"i!>!>e!>},<>,{{<'{!!!!<"a'ou!>},<>},{{}}}},{{,,{}},{<,!!!>!>},,,<},{}}}},{{<,o!!o!}'!!!>},<,!!!!o}!>},,>}},{{{<,!!a!>>}}}}}}},{{{},{}},{{},{}},{{{},<'!!!!!>!!,<'u!!u'!>!!}!>,<>},{{{<}"u!>!>,i<"'i!i{!!!>!>},},{<{,!>!!oa{,a,'!>},}},{{},<""!>,},<"!!!>!!!!!"!>},},<>}}}}}},{{{{{},{}}}},{{!i!!""""e>,<}>}},{{{},<,ue"eoo}"!!!>},!><>}},{{{}},{}}}},{{{{!>!>,!>},iue!>},<}!>},<},i>},{<{",},!!!>!>!!!!!>!!!>>,{i!>,,}}}},{{<"}!>},<''{!}ie}!au"},},,{{<>},{}}},{{{!!!>},},,,<'!>},},},<,u>}},{{{},<}!>},<,a<'u{,!>u!>!!!>!>},,}},{{{{}ou>}},<},{{},,>},{{!>}!a'!>,!!!!{>},{{!!!!<,!>u}!!!!e!!!>!i>}}}}},{{{,<}!a>,!!,"}<"!!,ai!>,<}u>},{},{{},},,<>},{u!!i!!!>!>"""!'ou>}}},{{{{},},}}},{{{{},<!!!!!>},a,!},{},{<"'{!>},u!!!>!'!}e!!aaa>,{}}},{{{},{},{{},},<>}},{{{{{{''{},<>}},{ei!>},<"e!!!>!!oo!>!!i>}},{{,<{ioi!>,<>,<,>},{{{eu'<>,!>!!a,>},{}},{},<{!o}'!!!!!!!>u!>!>u!!!!">,{}},{{},<}>}},{{}}}}},{{}},{{,{}oa!!!>!>,,<"!!'>}}},{{{{}},!e>},{,,!>,<<}},{{,e!{u<"!!'!!ioo},ei!!o,!!!>>},{}}},{{{,>}},{{},{{{!!!!!>!>}!>},}}},{<},}},{<{>}}},{{{},<>,!>,}}}}},{{{{{<{!u!!!aa,},,<>},{<},}},{{{{{},{<{","!!,o}!!,i!!u>,,<,a!!!!!>!!!>},!>},}},{}},!,'u!>,<},{<>,<>}},{,e!,}},{{{{{{<}{!a"!>},},!!!!u!'!>,!>!>,}},{,<"}iu!!!!!>!}>}},{<{o{!}>}},{}},{<>,<>},{{{}}}},{{<,!><{ii}!>,!>},<">},{{<'},,<>,},<{!!''}u!>i>},{},<{,{>}}},{!{!>},<<<{au!!!>e!!'!>,<,{i,>,{'},!!u"!e!!!!!>!>!,u,{!>,>}}},{{{{{a'<"!>,e!!"!!!!!>>},{{},{}}}},{{{{<'"o{!i!<,!"!,{<"!!o!>,!>!!!>{!>,,}}}},{{{{{,},},},'"}!>{'!a!>,}>},{},iu!u>,oa{'>}},{{{{},{{}}},{<{!!'>}},{{<>}}}},{{{}}},{{}!!"!!>,<',!i!,<!>,a!>},,<{!!!>{>},{{{!}e<'!>,,{}},{{,!>!>,<>}},{{{!!!>!!!>!'!!a{a!>},},}eae}},{},},!!>,{<'u,aeu!>},}}}}}},{{}}}}},{{{{},{<{!,>}},{{ui"!!i'au!>},e!!!>>},{{{!>},!}"!>!>,!!!'iee!!}>}}}},{{{},{<"!!,aa,{}}},{},{{,'!!!>!!<}!>,,<>}}},{{{<},iu!!a!>>},{{{<"i!!!>>},{{,e}!>,<"!>!o}!>,},{}}}}},{{,},,},eo!!e!u'!!!!!>{!!!!!!">,<{!!!>,o!!u"!!!>e>},!>,!!!{'!>},"i,},{,<>,<{aau{!!'"!!!!!i!!}}}},{},{{{{{,<'!>>}},{{{,<{>},{}},<}e>}},{},<{}},u!!}!{},{i'!>},<>},{{{<{'!>,<"!!,!}>}}}},{{{{{},},<{,u<>}},{<",!!!>!>},<"!!o!>!}!!!!i>,e!!!>},<}!!!>!!!!!>!!!>a!>},}},{{,<{>},{{},!!}!!i{!>,>}}},{}},{{{},{}},{{<,o'"{}!>},,{{!!io!!!>!>,},u!!"{!>},},!!{o!!!u}"!!!>u!i},,<>}},{}}},{{{},<''!u!>,<,!>!}"!>!!!>},!>},<>}}},{}},{{{},{{{{{},<'!!!>a!o!>},<>},{!!!>u!>,}},<"}!>,},!>,},{{},<{!>!>oiia!!!>,a!!u!>!!a!>},<>}}}}},{{{{<>}},{{{},<,<},e<>}},{{{<{!>,<{>}},<>}}},{{{},{{{},,<'i!>},!!!>!!{}>},{{<,ui!>,!!}}!'!!!!!>>}}},{{{},<,{!!",},,{},<'"!>},!>},},},<{!>},'aa>}},{,a!!!>!!a'}>}},{<''!"e{,,<>}}}}}},{{{{{{},{}},{},{{},<,!!,o'!!!>ea!>,!!!!!!!!!>,<>}}}},{{!>},a!>,,"!>,>,u!>>}},{{{{<!>}!!!!!!!!!!e<,{{o!!!>!!!>'"e'>},{,}}},{{<}!>},{!>},>}}},{}}},{{,<""!!!!!>">,{}},{{},,}}uoou!'!>},<'>}}}},{{{{,,<,,<!>,},{},{{{!!!!oe!>""},<,>}},<,!e!<>}},{,<"!!!>ii}"!!o!!!>!!!{!i!!!>},<"!o!!u!}>},{{{<'!!"!>ea'}!>},<>,<}!>,<>},{{},,,},,,<,<}>}},{{{{<"}!!e>}},<}!>},!!!!""e'!!!>u'!!!i!!!>!!!o!>,,<>}}}}},{{{{!>},<{!>!!{>},{{u!>},>}}},{{}},{a>}}}},{{{}i>,{,<!!'i!!,a!a}>}},{{{}},>},{{{{,,<}}}}},{{{<{,,<'!>,!>},<,>},,<>},{{},<>,,e!>},<}"!>!{!!!!}i!i!!!>u>},{{{},{{}}},}a,{'!>,<{>},{{,<"u}>}}},{{<'u!>,},<},>},<{e>}}},{{{{<{ouu},,!!e}i!!a!!">},{},!!!!!>},},},{{{>},{{a!>,,,!!e!>,<>}},{{{a'a>},<>},{,!"!!!>,,>}},{{{{<'a!!a!iae}u!!!!a!!"!!!>'!>},<>}}}}},{{{{},{!'>}}},{{{{},<{,oaa!>{,}},{{{!!"{>},},}},{{<'!ia!!!>>}}},{{ea!!,<}!>!'i"!!e'}!{!!>,,!!{!>!!!>},}},{{<{}!!!>"!},{{{{<{e'e"!>},,,<',!o!!!>,!!!>oe,{<'!!!>!>!>,}}},{{<'!>},u!>!!!!{!>},<{'!>},<">},{}},{{<'!{"!!!>!!"">,<'ei"!!oa>}}}},{{!'e"i{i!!">},{}}}}},{{{{<"i>,{}},{},{o>}},{{{!!!>},!>,},{}},{},,<>,{}},{!>o"!>},}},{{{<}!!'o{!>},},}},{{{,},{{,}}},,<'o},a{!>u!!!>},},!>,},<>},{{{<,{},},<},!!}!!!!!>">}}},{<>,{,!>!>}!>,},}},{},o{<}!<,e!>,>}}}},{{'!>",u,!}<,!!!>},<>,{{},{,<}o{"!!!!u!!o!>o>}}}},{{{},{<'!e'!!!>!!!>a!>},!!!!i>,!!!!!!!>!>,<"!!!>!"',}uo"!!o>},{{!>a"o',>},{{{{},<}!>},},<'!>,<>}}}},{,!>!!!>!!i>}}},{{<{oa<}ou!!aa!!!{>,{}},{{{<{!!e}e!>!>,,!!!><>}},{}},{<>,{!>},!!!!ae''!!"u!!!>,}}},{{<}oi"uue!}eiu>,{!!}o,>},{{},{{<}!>,},!!!'>},{{},o>},{<,!"'!>'e'!>!>},"!>>}}}},{>}}},{{<}!>},<'!>,!!}!>,,},{{{,}},{{{u,>},{a'!!i!!!>u>}},{{},{}},{<"o!!'<,<}},{<,o!!!>!<,>,{}}},{{<}>},{<"!!o'!!a!!!>'>},{{{{,,},{},<>}}},{}}}}}},{},{{{{},{}},{{,,<}o'!>,,>,{{!!!>}}{!!!>!!i!>},<>}}},{}},{<,<'!!!>ei!>,},},<>,{}}},{{{},<}!<'{!au!!{!!}>},{<'u!!{a,!!'!}oo}},{{{<'!!!{!!!>!!a!>>,<'<"'!i}o!u>}},{{!!!!!>a}!!!!i!!!>}>},{>}},{{{{,<>},<,!u,!!e{!!i!>,<,!>},!"!!!>>},{},{{{<,}}"!!!>u<>},{}},{{!!<>},{}},{<{!>},},,,!{!!!>},}}}}},{{},{}}},{{{},<{}'{}!!ao,>},{{,},<{!!!>u!!!!!>,<},{{},{<,>}}}}}},{{{{{{},ui!!}!>ao!,>,{<,o'a!!!!!!!>'i>}},,<{au!a!>,,<>}},{{{,,},}},{{<"!!u"!!!ao'>,{},<o!!!>e>}},{{{{},{,{,<>}}}},{{},<"{>}},{{,!>,,},<{>}},{{{,<>},{<{!>,!!a!!e!!',i>}}}}},{{}}},{{!>},!>,<'o<,i'!>,,<,!uo>,,'{i!>"!>},,<}!'!iu>},{{},}}},{{}},{{{{},<,!>},},{}},{{}},{{,eee!!!>!>},,<"!!>},{}}},{{{{,},},,{!>!!!>'!>},}}}},!>,}u!!>},{{},},<'o!!!>{!!!>},!>},<,"!!!>i'>}}},{{{<,!!},,<,!!!!!>,!>,'!>},<>,{!ai!>},}}},{{{,,<'!"},>},{}},{{},{ao'{!}<>}}},{{<"a!!!<',!,ou>,},<,!}"!!!i!>,<},},<>},{{{},"!!o">},{{<}!>},,o!!e{,<{>}}},{<>,,<}!>!,ouiou!!'o!!!!!>i{>}}},{{{{<"!'}>}},{},,!!!>au!!}e!>>,<"!!a!!!>,},{},<},<{>,{{},}"{"!>,},<>}}}},{{},{{{{!>},<""'o!>!>>}},<},<{!!!>o!!{'!>,},},{{{<,<",au!!!>!!"!>!!!>!>},<'e!>u>}}},{{!!!>,!o!},<>},!>,!>},,},},}}}}},{{{<>},{{},<,!>},},},,,},{{<},{},}}},{{{},>}},{{o>,{,,!>!!e!!!!}'>}},{{}}},{{{{,,,<"!!!!!>a{,!!!!!!"a'>,}},{{{{}},{},{,}!!},<'ou!>,,}},{{{{,,<,!o}">},}},{{<}!!,!>,"!>,},a!'!!!>!!!>>,}e!!u!!!>}}},<<>},{<{,>}},{{},'!>!!!>!!>}}},{{!>},!>,<'!!!>'!!e!!{i>,},"i!>i'!!,e!>,},<},},{{{<"!!},<,!>,}},{{},<"!!i!!!>,},{{{<}{!>,},<>}}}},{{,!>,,<'o!>,<,,!!!>i!>},},!>!!!>,},},<}o'!>,,<>},{,,<,!!!>u!!!>,>},{{!,{!>},},,e!'oe!>,<'!>},},{{},<}"!!!>!>,,},{{}}}}}},{{<>},{<{!>!>!!!>!!!>!>,>}}},{{}},{{{{}}},{}},{{},{{{},{<{!>,<''!>,<',,>}}},{{<e,!!!!a!!<"u{!>},},},<'>}}}}}},{{{{{},},!>,<>},{},},<}>}},{{<{!!">},{<<>}}},{{{},{'!>!!'i!!!>},}},{{!!>}}},{{},,,a,>,{{},<,{e{!>,}e!>,}}},{}},{{{{{{<{e!!!>!!!>!!!>,,<"{>},<}<},{{},<}!!!>'!!ee!>!"a!!a'a!!!>},!>},<>},{!!!>!!!>!!!!!>!{!>>}},{}},{{{ue""!>,<>}},{{},,},,},<>,<>},{{{}o!!"i!>,<"!!!>{"o!!!>>},,<"!>},<}!!o'!>{e">},{{!u},{',!!!>!eo{oe!>{>}},{{!!!>i!!!>!!!}'>,},<"o>},{},{{{<}a!!}!!}u!>,e'!!!>,<,<>},<}!>!>},!>},<,},o"u!!!!!'{!!!>>},{{{,{{<{}'>}}},{{{u>},{{<>},{<{!>},<>}}},{{!}!!!>!"!>},<"<<>,{!},!!!>!>},},>}},{{},<},<>,{<>}},{},},,<}u>}}}},{<}'!>},<<"u!!!>!o!>a>,{<'{a>}}},{<<,!!{!!!>,!!,'ua!!!!!!!>,,},<'!!!!!!>,{}},{{<"e!o!!a,!>,!u{<>,,,},,<a!>},,<}o>}}}}}},{{<'{!>,<}""!>,!e"e>},{>}}}},{{{<"!!!,u,!,!<},>},{}},{,,<}'{"!e'o!!a!!!>!!{}!!!!>,},>},{}},{{{{},!>,,<'e!!!>!!o!>!"!>},},<"a!>,<'>},{},,{<'o!>!}}},{{{},,<,}i!>,<{!>},},<},<>},{{{{},<,,{!>,},<',u"!o>},}},{<'i!>},,,{}},{{{{}}}}}},{{{{{}}}},{},{}}}},{{},{}}},{{,!!!>!!u'i!>!!!>!!!>u{!>},!!!!!!!>>,{}},{{},{{{{},{}}}}},{<,!!!>'}eu<}!ii!>,,<'i}!>o>}}}}}} diff --git a/09/lib.scm b/09/lib.scm new file mode 100644 index 0000000..5eac027 --- /dev/null +++ b/09/lib.scm @@ -0,0 +1,70 @@ +(library (lib) + (export solve-part1 solve-part2) + (import (chezscheme)) + + ; Global state... a sin, but very convenient in this case! + (define chars '()) ; Characters still to be parsed + (define part1-total 0) ; Total score of groups in input + (define part2-total 0) ; Total non-escaped garbage chars + + ; Is the next character in the stream equal to `c'? + (define (peek? c) + (char=? c (car chars))) + + ; Blindly accept character and pop it. We do all detection + ; via `peek?', so we don't care what gets discarded here. + (define (next) + (set! chars (cdr chars))) + + ; Parse a "group". We can assume all input is well-formed, + ; which really helps keep this code as simple as possible. + (define (parse-group depth) + (next) ; Accept initial #\{ + (let loop () + ; Expect start of "group" or "garbage" + (cond + ((peek? #\{) + (parse-group (+ depth 1))) + ((peek? #\<) + (parse-garbage))) + ; Expect comma or end of current "group" + (cond + ((peek? #\,) + (next) ; Accept #\, + (loop)) ; Parse next "group"/"garbage" + ((peek? #\}) + ; Add current group's nesting depth to total score + (set! part1-total (+ part1-total depth)) + (next))))) ; Accept #\} and return + + ; Parse "garbage": everything until next non-escaped #\>. + (define (parse-garbage) + (let loop () + (next) ; Accept char (#\< at first) + (cond + ((peek? #\>) + (next)) ; Accept #\> and return + ((peek? #\!) + (next) ; Accept #\! + (loop)) ; Continue to escaped char + (else + ; Add this character to the total count + (set! part2-total (+ part2-total 1)) + (loop))))) + + ; Reset global parser state and parse the input string + (define (solve-puzzle str) + (set! chars (string->list str)) + (set! part1-total 0) + (set! part2-total 0) + (parse-group 1)) + + (define (solve-part1 str) + (solve-puzzle str) + part1-total) + + (define (solve-part2 str) + (solve-puzzle str) + part2-total) + +) diff --git a/09/main.scm b/09/main.scm new file mode 100644 index 0000000..b4b540a --- /dev/null +++ b/09/main.scm @@ -0,0 +1,14 @@ +(import (chezscheme)) + +; Where the magic happens +(import (lib)) + +; Read my personal puzzle input +(define input + (call-with-input-file "input.txt" get-line)) + +; Part 1 gives 21037 for me +(printf "Part 1 solution: ~a\n" (solve-part1 input)) + +; Part 2 gives 9495 for me +(printf "Part 2 solution: ~a\n" (solve-part2 input)) diff --git a/09/test.scm b/09/test.scm new file mode 100644 index 0000000..6d232da --- /dev/null +++ b/09/test.scm @@ -0,0 +1,68 @@ +(import (chezscheme)) + +; Where the magic happens +(import (lib)) + +; My quick-and-dirty unit testing framework (copied for each day) +(define (run-test name proc input expected) + (let ((result (proc input))) + (if (equal? result expected) + (printf "\x1b;[32;1mPASS\x1b;[0m: ~a\n" + name) + (printf "\x1b;[31;1mFAIL\x1b;[0m: ~a: got ~a, expected ~a\n" + name result expected)))) + +(printf "Part 1 tests:\n") + +(define (test-part1 name input expected) + (run-test name solve-part1 input expected)) + +(test-part1 "part 1 example 1" + "{}" 1) + +(test-part1 "part 1 example 2" + "{{{}}}" 6) + +(test-part1 "part 1 example 3" + "{{},{}}" 5) + +(test-part1 "part 1 example 4" + "{{{},{},{{}}}}" 16) + +(test-part1 "part 1 example 5" + "{,,,}" 1) + +(test-part1 "part 1 example 6" + "{{},{},{},{}}" 9) + +(test-part1 "part 1 example 7" + "{{},{},{},{}}" 9) + +(test-part1 "part 1 example 8" + "{{},{},{},{}}" 3) + +(printf "Part 2 tests:\n") + +(define (test-part2 name input expected) + (run-test name solve-part2 input expected)) + +(test-part2 "part 2 example 1" + "{<>}" 0) + +(test-part2 "part 2 example 2" + "{}" 17) + +(test-part2 "part 2 example 3" + "{<<<<>}" 3) + +(test-part2 "part 2 example 4" + "{<{!>}>}" 2) + +(test-part2 "part 2 example 5" + "{}" 0) + +(test-part2 "part 2 example 6" + "{>}" 0) + +(test-part2 "part 2 example 7" + "{<{o\"i!a,<{i}" 10) -- cgit v1.2.3