From 07f57212cb6dd633364a4540813c23fc25b36599 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 14 Dec 2017 22:05:16 -0500 Subject: Day 9 I was really sick at the start of the week, okay? --- 2017/input/day09.txt | 1 + 2017/src/bin/day09.rs | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 2017/input/day09.txt create mode 100644 2017/src/bin/day09.rs (limited to '2017') diff --git a/2017/input/day09.txt b/2017/input/day09.txt new file mode 100644 index 0000000..32a8b51 --- /dev/null +++ b/2017/input/day09.txt @@ -0,0 +1 @@ +{{{{{{},>}},{{{{{{{!!!>!!}<>},{}}},},,!>!>,},},<>},{,}},{}}},{{{{,<{>},{}},{{{aa>},{<,oi!!!>aa,!!!},}},{<"a!>!a,{"!o'!>,,,i>,{}}}}}},{{{{{{!!!>,<{!>},,,<<">},{{a!>!!!{"{ao!>},aa!!!>!>},<"!>,!>,<>},!!o!>,},{<}!'i,!!}e!>,},!'>,{}}},{{{{{{{,o!!!><",i!>,,uuao>}},{<}<"a{!!!>!!!>,u!>,>,<"!!!!<}!u!o}'!!e!!!>a!!},,!>}!!>}},{<">,,<>},{,<}!!{!>},,>,{,,<>}}},{{{<}!!{!!!>i,}'!"ooo,!!>}},{}},{{{,'!>!!!>},<{!>},<{},}}}},{{<"',,',a{i!oi,>}}},{{!!'}e!>{,!!!!!>"a!>},<"!>},<},!!i>}}},{{{{<"{!>!!u!{"">,{<>}},{{{}},<,!>,},<>}},{{<{!>,,,<<},>},{}},{,,},<{>,{<,!>,},},"eu!u!>},<{>}}}},{{{,!!}o>,{},<<>}},{{},,<"!!!!!>!>,!>",<"io>},{}},{{,">,<">},{{<}{>,{{,{{{},},<,"!>,!>!>,},}},{{aa"!>oa"!!!>!>>},{}}}},},}},{{{<{}}">},{<{"!>,!!'}!!!>},}},{u}}!,u!!!!!>!!,e!!!>"!!!!'}!!!>},<{>},{{{a!,"!>,<,}ua'!a>,{{!!",}'!!i<<>},{'!>},}}}},<!!!>>}},{}},{{{},o!!>}},,>}},{{{{},<,,<}!'>},{{{{{{},<'{,!>},},},<<>},!!!>,}},<'}!>},!>},<<}!!"!,!!!>,},{{}}},{<'!!!!!a'!!oa>,<"{"!!,!e!!}<'!>}!!!>i>},{<,!>},<{}!>},},,>,{<!,!"!!!!,!!!>{!>},>}}},{},<""!>,},,<>,<{!>i{!!!>!>!!{!'ee>}}}}},{{{<""!}<!>!,!>},,>}},{{},!e!>!!!>ui!!,,!!!!!!!!!>!!>}},{{{{{<'{!!!!i'!>,!>>},},{{},<,{!!!>"!>},<,!!!>,<'!}o>}},}!!!>e"!>,<{{!>,,,!!!>>},{<,!>,}}},{},{{{}},{<>}},{{{{{ii"!>,<"}}},{{{}},{}},{,<,i!>},<>,{,<,,<'!>'>}}},{{<}u>,{}},{}},{{{},{!{!!!>},}},{{<"ooaa<,!a!>},}}},{{{}},{{,{"e}!!,!!!"!!,!!!>,},},}},{{},{!u!'!e!o!>,,<<'>}},{{{{}},{!>'!!!>!!!!!!!>!!!>,<>,{,<'},!ii!"<>}}}}},{{{{{},}!!!>},<{e!!!'{!>},,<<<>},}},{},{}},{{{{}},{,<},,uiie'!>},!!}>}},{{},{<>}},{{!!!!!>,}a>,<{!!>},{<>,},<>},{{}}}}}}},{{{{'!!!>a!>,,},{{<>}}},{{},},,<},<},!>},<>},{<>,,!>},,}},{{{<,},{}}},{{{{}},{{{{!>},<"}!>'!>},!!<'}i!>!!>},{{{,{}}},{<}!!!>"!a,u!!'ou!>}!a>}}}},{{},{<}!ae!>,<"!>,{,>}}},{}}},{{{{,>},},!!!>,<,!>,},}}},{{{,a!!!>}}!>},,},<>,,},},{{{!!"a"'}>},{,<,,e!>i{>}},{<>}},{{},{{,!!!>!!!>i!>,<>,{}},,!!ii'!!>}">},{<}a<,!o>}},{{{{},<,e!!!!!!!u>}},{},{{<"'<'>,{!!{>}},{<'"!!!!!>'!>"{!>!>},},},{}}},{{{},'e!>},e"!!!>,},<}eo!>,,<,a>}},{},{{}ie!!}!!i',>},},{{!!!!'!>}a"!!!>,>}},{{{,<{aa'{oa!}!!!>i>,<,,!>"!!!>!>,<}'!'i>},{,<>},{u!!!"a,"!>},ea!!!!}!>,}},{{},{{{<,o"'>}}},{{!!!>!>{,'ue{'!!!>>}}}},{{{},o}!>,,'"!!!!}},{{{{a!>},<''!!o!!!!!>ii!>,>},{<'"!!!!{!!!!!>!>},<}>}},{{,,,<!>},<>}}}}},{{{{{{{}},{{{{{<{!>ie,!',!>,}a!e!!!!'!!>},{,},!!!!{>}},{},<,"{!!!>'o}!>,<'{>,{<>}},{{},{}}}},{{a'!!!>,,},},!o'{iei!!u!>o{'"!>},<>}}},{<{!!"u>,<}!>,<>}}},{{,<>}}},{{<{!!,!o!!!>}"!!!>!>},!>},,<'!a!!!>},<,!',{i>},{{},,<'!!<>}},{}},{}}}},{{{{{},{}},{!>,}},{{{<>}},{{o!>},!>},<>},{{},u"<<,'!>>},{<'!!!>"!>,,},>}}}},{{{{{},,},<>,{}},{{,{}},}i!!'u!e!!!!'!>,,<,!>,<>},{{{!!!>a}uiu!!>}},{,!!!>,<'!!!>o>}}}},{{{},{{},<{"o>},{{},{{{}},{,<,!>,u!!ii!>>,{<'!!!>!!!'!!i{!'<>}},{,!>!>},,{}}},{,<>,{!!"}!>},!'ei>}}}}},{},{{{<{!!!>>,{,<'<>}},{{i!!ae,,<}!!}>},{<,!!!>!>i>}},{{{{<,eo}!}o!>},<"!!'<{,},!'ii,}!!!!e>},{!!!i!>,},e!!!>{!!{u!>},}},<,!!{uo<'!>!!"}}>}},{{{},{{!"o},{,<"!!!u!>!>,!>,>}},{<{'e{!!"!!}!!"a!!!>i>}},{{<'!<,,}>,{!>},},,,e!!"eea!>ie>}},{},{}}},{{<"{!>},,<}!!!>!>,!>,<>},{{'!>!!'!>,"io!!,!!}{!!!>,<>}},{{{,>},{{<"!!!!!!}!>,,{},<',!>},<'!!!>,},<,!!!>!!e!!!>},<}},{}},{}},{{{{{{},<'>}}},{}},{{!>!!!>!!o>},{<,u"!>},<'{!!!>{}{>}}}},{{},{<u!!,!}}}},{{{{{,<"!!!>a!!!>{u!!!>>}}}},{{},{{!!!!}>,{},<,",e'"!!!>!!!>!>},}},{{!>!!!>u!>},<"e<,{}},{{},<{!>,ou{!!,!!i<{o'i!>,}},{{{{},},!>},},{{{>}}}},{,,<{!>io,!""o!!e""aee>,}},{{<'ue{'u!!!>,!!u!>,!>o!o!!{>,,!>,},{{}},{{{},}},{}}},{{{}},{{,>}}},{{<''!!,!!">,{<!>,,!>i>}},{{<,}u!!!>},}}}},{{{!>,,,o{!!>},!>},,!>},,!>uo>},{o!!!!a!>!!,u!!a!!!>!!!!!>"!!!!!>>,{}},{{},!!"!>},',}}}},{{{{},>,<>},{<>}},{}},{{}},{}},{{{{<,u!<"},,}a!ou!'!>},<>},{{},!!a!>}},{{},{}}},{{{{{{},{}}},{{{},<}a"aaa!>"o!>,<,!>},<{!!!>!>,<{>}}}},{{{,<!!!>!!a,"},,{{!!'!u<>}}},{!!!>!!i!!!>!!"{!!!!!>>},{{!>},,},>}},{,}},{{{{{{<{uu<,o''}!!!!!!!ao,<>},{{},{{<,a!!!>!>!>,<"u,<,!!!>!!uue{!>,<>}}}},},{{},<'e{e!!!>!},,},{{<},<>}}},{{!>},,}!!i!!!>},,},{{{},{}}},{<}!!a'"'>,{{{{},{}},{},}},{ao!!''!!!>,},<,!!!>!>},}}}},{{a>},{{,,,!!i!>},<>}}}},{},{{<,ei'{,ea!!uo!>,,<>,<,!>{!!!!!!!>>},{},{{!!!>!>,<>}}},{{{<,i}u!!},!!!>{>},{{{!>,!>}>},},{{{{},}o{!!!>!!!>u!!ioe!!!!!>!!!>},<>}},{{}},{<}!!!!'"'a!!{!>,<!!o',!>,!{!>,,<>,{},}}},{{{{!!!>!!!!!>ao!>,<"{!>,e'!>,<>}},{{{!!}<<,>,{<}<'''!,!!!>ea!!'!{oi!!!!ao!{">}},i>}},{{,,<}{e!!'!!!>u{!"!!'>,{{},{">}}},{{{<>}},{}}}},{,,e'!>,,{,!>!>,"!>!>!}"o'!!!>!e>}},{{<'{{'>}}}}}}},{{},!>},<,"'ia!!!!!}e}>,{<>}}},{}},{{},!>,},!>,,,<},ou!!,!>,oi!!}>},{},{ae!!!>!>},<>}}},{{,,},,>}},{{{<,!!e!!'a!!'o!!!>,},{}},{<>}}}}}},{{{{{{{,,<{>}},<>},{},e!>},<',>}},{{},<}">},{,!!!>'a,!>,<}!}'!!',,},}},{{{{,!!!!!>ao>},},<>},<}aa,uu>},{{},{},}}},{{},,{{{{<}!!!"!>,o>}},{!>>}},{}}},{}}},{}},{{{{},{{<"'"uei{'a!u!!!>},},<"u!!!>},<{!!a!>i!!e!!!>>}}},{{},{{{!!!!"u{!>,<}>}}},{'!>,',!!!>oe"'uu{oa}<>}},{{{<>,{{<,!!!<>},{}}},{{},<}}},{{,<'!!e!!!!!!!>,,<"u!>i!>}!!},{{<"a!>,},!!!>"!>o!!!>u!>},},<>}}}}},{{{},,<,'{oi,}ia>,{{{{{{{},},a'{i'i>}}}},},<"}i<}!!!>!!!>i>}}}},{{a>},{{!>},}}}},{{{}}},{{{{}},{{{eua{}}!>},},<}!>},},{<,!!}"ei!!">,<},,}},{}}},{{{{>},},},<,{>}},{<}!!e>,,!>},},{{<,!!e!!!>,,{!!}}!!},o!>},}}}},{{{{{},{}},{,,<"!!!"!}!>},',,},{{},{}!><>}}},{{{<""!>!>,},!!!><{!!!>!!e>}},{{,!!<'i>}},{i,!>!!,i'a>,,,,<>}},{{},{{{,o,!!}!>!>!!i!!{u!>},<>},<"!>},,<{!>!>},<!{!!!u}e!>},},<"!,!">},{{},,<>},{{<>,{}}!!,!>,}},{,{!>,,!i!!!>>}}},{}}}},{{{{,>},<>},{<{o"{e!>,>,{<>}},{<{!>},},},<}u{,<{,!!!>!!<>}},{{!!i'>},{},{{{}},{{{a!,!!!>},},>},{{{}i,e!u>}},,'o!>,<}'!>,}},{},,}},{{{<>},,!!}!iaue!>!">},{{!!!>},,!>>},{{{},{}},{!!!>o!>},,{",},},,}},{},<>,{<>}}},{,,<!!{ui{>}},{{!>},!!!a'},<}!>>}}}},{{{{{{{{,<"{!>,,{}},{{,!!!>},<''e!<>}}}},{<},o!!i!!!'!>,o,!}e!!!>,!>a>}},{}},{{},!!!>u!>!"i{!>,},<'!>,<>}},{},{<>,{<"!>,},,<"!!!>!>,e{!!!>!!!!!!ue<>}}}}}},{{{},},{{oa!!o,},<<'!{>},{},e!!i,"}!>!>},<>}}},{{{{{{{<}!'!!}!!e!>,<>}},{}},{}!!!>"!>},<>},{{,i,>,}}},{{},{}}},{{{o"uu>,{ii!i<>},<'oe{!>>},{<<'ao!!u!!e!!!!!>,}},{{{{{},,<{!ue'io!!aa,>},{}}},{{{{<'!!!>!>},>}},{<'!{},},{<,!>,<{>,{<}>}}},{},},{{{{},},},{{{o!>!!a!!'"!>!!!!!>!>"!{!>},<>}},,!!!>>}}},{{}},{{,!>!"!>a">,{<}>}},{}}}},{{},{},"",{"i!!!>u"a!!,>}}},{{{{{{},{{{},<'!'!>},}}},{},{ooiu!>},>}}},{{},<{!!,ue!>,"!'!!'u!"i!>,<>},{{},{!!'ueo>}},{{{<{!>!!a!!!>!!!>'!>'!!},},},{{},<'i!!!>!!o"!}!u,i"oeu"",>}}},},<},<}o"i!>},<>}}},{{{{{{{!!!>},},<>}}},<!>}"!>,},{}},{{,},e'"}>}}},{{{<'!>},">},{}},{}}},{{{{{,!!!>!!!!!!!>!u!>>},{},},}},{{<}o}!,!>},},<<<,,<>},{<,!!!>,}},{}},{{{"uii!>},!!!>>},<,>}},{}},{{{<,{,,!>,,{{}}},{{<}!!a!{!!!>oi'a!>,<{{,'>},{<{o!!,!>,e,o}u!>},<>}}},{{,<'o!!!>'!!}!!"{ue"!>!!,>},,!!"oie>},{{},}ei>}},{{,<,!!a}>}},{{{},{}},{{{<!>},,<}i!>e}o!>,,'>}}},{{{{<}!>,<>},{{{},{<>}}}},{}},{{{,{<{{"!!>}},{{{{,u!!eao}'!!!>},},}!}>},{!>ui>}},{{'uo!>!!!!!>},!!!>>},{<,<'!>},},!!<>,<,{!>eu>}},{{<>},{}}},{{!>},,!!u}!!!>o!>},<>},{}}}}},{{{<"!>>},{}}}}}}},{{<>,<'!>!>,!>},!<>},{{<,o'"ia!>e}i,ie,u{!>},},}},{,},,},'o!!!>!>!>,<{"i{!!}},{{},{{},,,<"!>},<,>},{}},{{<"oi>,,<,oi"euuoo!>!>,,}}}}},{{},{{}},{<>}},{{{},<'>}}},{{{{},oiae},},}u!>>},{{,a!!!>i"!!"!!'>,{{},{}}}},{{!!"!"!e!a!!!>i!>},},<},,<>}},{{{!>,},<>},{!!!>!!!>},},e!!"!>,<>}},<>},{{},{}}}},{{<,eo!!!>}!>,},<>,!!!>}e{!!!!!>!!"u<>},{},{<<},!!!>u!>},},<>,!>},,i!!!>"!!!>!>},}}},{{{!>},,},,>,{{,<,}!!"ei!i!!,a"'!>e,},<>}},{{{{<<,!>},'!>,,!!!eu{!>>}},,,{!!!!>},{},{<"!>,,,,},,<'!}}},{{{{{,i<'eu!!!>!>,>},{{}}},{<"<{!>!>,,<'{!>},},}},{{},<{}!>!><'!>},<<>}}},{},{{{{{a,!>},},{o!!!!!>!!}u'i!>},<>,{a!>},<},},,<>}}}},{!!}{!>},<>,{<,a>,{{,<}!!ia,',>},{{},,!>,<{,!",>}}}}}},{{{{},<>,{{},,,<,'!i,eo>}},{,{}}},{{{{<,!!!>,},<>,{}},{{{},{{!!ue!!oo>}},{,,<'"!!!!u}"!!!!!u!!!>>,<,!>},,<>},{{<{e"!!!e,""o"{'!"!!!>a"!<>},!!!!,}}},{{{{,{<>}},,!!!!{'u",i!!!>ae!>},},>},{{<>},<>},{{{{{{<'e!a!>!'},!!!>,!!,!!!>!,i!!!'!!!>,!!!>>},{}}}},},<"!>,<'!!!>,,!>!!>}}}}},{{<o!,!>},!oa!!!>!>},<'>,{}},{{{},{<}u!!e!!!!!>,<}!>,},}!!>}},{{{<{e!>},<}!>,!,!{iu>,{}},{{},{{,<{>}}}},{{<{a<,!!!!!>!,{<}i!!'e!!e}{<"!>},},<'e{aa>,{}}}}}},{<<}o!>,},<"{,"!!!>!>,'!}>,{}}}},{{<}!a!>},<'!!!>!u{!!!!!>!>ioai{'>},{{{}}},{}{o!!!>},},},!!{',>}},{{{},{{<,!>!>!>},,!>},>}}}},{{>,{!"{}}!>,<'!!!>!!o>}}}},{{{!!e}e!o"!!>,<!!!>,<,!!>}},{<"!!!>!!!>o,!!!>>},{{}}},{{},{<}!!o!}ua}!>},<,{i<>,!!!>!!!>o!>,!!'u!!}!>,<"!!>}}}},{{{{{{<},<}!!e<{>}}},{{<>},u!>"}i!!!>,<,}}a!!!>!"!}u!!'>}}},{{{{{<"!>,,},{}},{{<'a<>},}},{},{}},{{{},{<}'"i{"!iou!!!>!!!>},},<>}},{{<'"!!!>e!!au'!!!>>},<''"ui!>,a>}},{{{}},{},{}},{{{},{{<'"!>,{>},<'a},"oee>},{}},{<},o{!>,},>},{e!>!>,"!>>,>}}},{{<'!!!>!o!}!>,<,!e!a!ao>,{}}}},{{{{<{}!>,<>}},{{<}oa,!!e!>},<},{!!!>{!a,u>},{<'!>,}},{{<"!!!>,!!!>!!!!!>!!a!!!>,>,{,!!>,{!{o>}}},{}}},{{{}}}}}},{{{{{}}},{{!!!>"oeai,!>},,},}e,{<"{}!!!>a!i,!!i!,'{!!},,>}},{!>},,<>,{,{<{!ua!!o!>},},,,!>oiu}>}}}},{{}}},{{{{,<'"!!ii"!>},{{<>},{}}},{{},},<,<},},,,>}},{{{{},,,{''ae!>!>},},<}!!!>",e!!{u{>}},{}},{{},!>!>,<{!!uu>},},}},{{{o!>,<',{!>},<>},{<<"u!!},<"!>oo!}!>,,},}},{!!!>u!,!!!>!!!>'eio'>,{{}}},{},<"!>},!i!>o>}},{{{{},<},,"!>>},{{!}}ioui'>,{,!!"!!'!}}}},{{}}}},{{{!>!!a!>},,<,!>},<{!>!>}i!!'u,!>,,<'a{>},{},,o!>,<"!!!>>},{{{{{},{},,},<'!>!,'!>},,},}}},{{}}},{},{!!!>eo"!>,>,!!i!!!><>}}},{{{{{}!>>},{}},u!>},}},{{{{}},{<,!!!>!<},<>}},,},{{{{<}eu>}},{},{{{},,{,!!!>>,{{{},{}}}},{,}},{{"a>,<{o<},"!'u}u!>},<}ue>},!""'>}}},{{!},},"!>{o>},{{<}"!e"o>},{}}}},{{<"!>},!,}eu"a!!!a!>},},<{>,},{},{{{,<{'!!!!},!!!>>}},{}}},{{{<""{!>!!!!aau!!!!<>},},<"!!}}}},{{{{{{},{,!!{!"e<>}},{},},!!e!>},!>},,<"!!,}!'>,{},},<{!>},<<"!!!>,}},{{{<{!!u,!e!a<}>},{}},{{{}}}}},{<}!>},,,<>},{<,!>},,<'<"!!!!!>{,<>}},{{{!!!>!u}!>},},<">}}}},{{{,>},{{,<",o!>{>},{}},{}},{{{{!>!>,u!"u!>,}}},{{},a!>},!!}!},{<{!>},{!>},},!'o!!{i!>,,!>},}},{{<'ea}a!!}!i>},{},{u{,},,,<,!">},{{},,<>}}},{{{}},{{{}}}}},{{{{},{}},{},{'a!!!>>,{a,,!>,,<{!!!>ee>}}},{{{},{{'!!,""u!>},<""u!>>},{}}},{{}},{<">,{<}ea!!!>,,},>,{}}}},{{{{{{{<{u"!}"!!>}}}},,>},{}},{},{{{{<,"!!""ue!!>,{<}''eoiae'!ae!>},},}},{{,!!!>!!"!!!>!>!!i!,!!!!e>}}},{}},{{},a!a!>,<>},{{},{!!!"!!!!",{>}}},{{{<{!{!>,},},<{>},!!>}}},{{{{},{}}},{i!!!>!}o!>e!!o!!i!!}!!!>!!!!"u!!""!>},<>,ei!>,ee>}}}},{{{{{<}!>,},<'o!>,}},{{},<>},<}!i!!"!!,!>!!!>!!}i!!<'!>},u}{>},{{,},ue"!!o'!!,u!!!>!'!!'o}'>}},{{{},{}},{{}},{},,<,,>,{{}}}},{{{'>,{"!>},<>}}}}}},{{{{{{{{},},<,>}},{{,{},},}},uo!>,!>!eu!e'!>,}a!!',!!>}},{{{<'"}!}!>,!>,i!>},<"!!!>},<'a<>},<}",!!!>,i{!'!!!>e,'!!'u!!!>'>},{},{{{},{},{{<"!!e!!}!>e,<>},{>,,},{,,uaa!!e>}}},{{<{{,,"{!}!>},,}}}},{}},{},{}},{{{{{{},},{,}},{{<{i!o!'>}},{{{},{<}>}},{{!},<>},{<{,"!!<}!!!u!!>}}}},{},{},}},{{{{}},},},i,u'>},{{{>,},<"!!!>!!i!o!!!>i,!>,>},{{},<}!!!>!!!>o!>,!!,!>,}},{<,!>},<,<,!>!!!{>}}}},{{{}},{{,i!!!!}!u,>},{{{<"u{,<"o"o!!!>,}},,,!>>},{{<'e!!"'ue!!!>!!}i"a!!"o">,{}},{,{}}}}},{{{{{{,},}}}},{<'u>}},{{<>},{}},{{<<}""!!iu!>,<"!o,<'}i!!!,<>,<>},{{<"i,"!!!>!!!>!>!>},<>}}}}},{{{uu!>},<},i}u!!!!e!{,!!!!!{'!!!>>,<{},},},{,<'u>,},!!!>!!!!'i!}{'!!!>",>},{{<>}}},{{{{{{},{u!!"!!>}},ai!!o!!a>},{{},{{<{,u!>"e}>}}}},{{!>},!>,<>,<""!>,}e!!}},{<{,iiu!!e!!iui}au{i">,{}}},{{},}},{{{}a!!,!>,,},!,'!!!>>,<>}},{{"u!!!>!>!!a<<>,<,>}},{},}}}}},{{{{},{{{}},{,{,},}},{}}},{{{{{}},},},<>},{}},{{{,,<>},a''e,!!!'!!a{!{!ia,>},<{oai!>!!!>!!!>,},},<,!e!>!!!!!>,>},{}}},{{},<{!!!>"!!!>}>},{},{},},<,>}},{{,},!!{e!!!>!!!>},,},{{{,},<}a,o<{a!!!!'u!!!>!!!>!!!>!>>},},!!!>a}!>},<}"a!!"!>,},{,},}},{{},!!!!!>!>{!!'!,}},{{,!>},a!{>},{{{!!!>!!"!>,},},,<>,<'!o'oe{!!','!>,a>}},<}!>},<>}}},{{{<>,{{,,,<",>},{}}}},{{{},{{},{<>}}}},{{{},!!!!!!!>!!e}},!}{>,!e!!i{o!>,<>},{{{,!!!>}!!uo,a!!{!!!>!"ee!>!>,<>}},>}},{{{<}!!!>,},},!>},,<>},<{!!!!'!!!>}>}},{{{},<}!!}!>,,<>,,},{},!!i,,{u!!!>},,u>,},{<}{!>},>}},{},{{},},,'}a>,{,<}>,{i!>,,a!!!!!><>}}},{{{<>},{!>,<'a!!!!i!>,<"o!!!>'uo,<>}},{{{}},{<>},{{}}}},{}}}}},{{{{o">},<"a!>,<,i!!}!!!>},,<>}},{{{}},{<{>},{"'!>!!!!'>,<<}!>},<"!!!!!>,}}},{{{{},{{},{!!,!!o>}},{}},{{},<"au!>},},{{},!!!>i,}!>},!>},<"!i!>,}},{{{},{}},{},,},<>}}},{{{{},{{{{,!!!{!>},<{o>}}},{{}}}},{{{{},},'!>},,,<"u!{a!!u}}>}},{{}}}},{<},<>,{<{!>,!>"<}u!!<{a}{{"},!>>}},{{{!!!>,},},<{"!u!>},<"a!o!!!,<}>}}}},{{<{e,!>'!!!>}!!!>>},{{<",o!!!!'!>,!>e,,a,<>},{{{!>,},<'>,{{e!!!!!!!>!!,<<,!!!!!>""'{!!i>}}},{{{<{>}}}},{{{o'!!!>!!!>{!!>},{},<'!!e{!>>}},,!o!>},<{,}}}}},{{{{{}}},{{,},{"!!!!!>u!>},},{}},{{{}},{{},<">},{<""!!!,a<}{!!e'>}}},{{{{!o,>},{<{}u!!>}},{,},},{{},!>,},<<,'}!ii!>},<'{>}},{{{o}{e>},},{{}}},{{{{},},{<"<>,{<"u!o!e}o,!a!!o>,{}}},{}},{{{<,u,!>},},o,!!,<,a!>,<{{'{!!{!>},<'},{{},<}>}}}}},{{{},},},{},{{}}},{{{>,{<>}}},{<},!i{!!!!!>'",!>},,{!i!i"!>,<},<,!>},<}!!,{e!u!!!!!<,e!!!!'e>}},{{},{}}},{{"a!!}!>},,!'<>,{!!"a!>!!!><,!!,ae'"a'">}}}},{{},{<,!>,'u>,{<{!!!u,"u!>,}},{},u!<>,,!!!>{ea!!,'!>},}}},{{{{{{},{<}!!ui'!!"u}e!''!>,<{e!>!>},<'!!i!>>}}},{{},{{},,>},{<{{oe>}}},{{{},{<'!!!,e<,{{'}!!{ia>,{{{!!ei!>},<<>},{}}}},{<,,<}!!!>,,{<}'i!!!>{i!!}}i<,!>!!o>}}}},{{<},<,{a!>},<{'!!a!!o!>,,{{,>}}},{{,},{{{,<"au,<">}},{{{''i!>,,<}oo>}}}},{{{<<,}>}},{<,!!!>!!<{{!!e!>},},i{u{>,<"!>},a'!e!>},<'!!!!!{a>},{{}}}},{{{},{{{,!}'"!!!>!!"!>},a!>,},},<{}!!!{'!>,<>}}}},{{},<}!>,}}},{{<"!i!aeae}u'e!>,!>,<>,},,<,"!!u>},{}}},{{{{<<}!!!>i"!>},,!u!>!>}o!>,,},{{{<oe!!}"">},},u>},{},{<>}},{"i!!u!>,<,!!!>},e"!!,,<}a!!!>!>>}},{{!!!!!!},<{uie>},},{{<,i!>,!!!>>},{!>,e>}}},{{<{e}!!!>!>},<"!!!'!>},},{{{{{<}"u!<,a!>,},<}!}ii}<}}i!>},<>}},{}},{,a>,{}}},{{{},},{{<'!>},<>},o!>,<""!!ue!!!!!>!!!>{!>,}}},{,e!>},!>'iu">}},{{{<}a!>},}!!!!o>,{,i!>,<"!!}!!a>}},},<{!!!>!>,<>},{{},,,!>!!!>,},{{{{<'e!!eei!>},<"!>},!e!>!>,"">}}}}},{{},{oe,,'!,!>""a!!}}}}}} \ No newline at end of file diff --git a/2017/src/bin/day09.rs b/2017/src/bin/day09.rs new file mode 100644 index 0000000..a8492d0 --- /dev/null +++ b/2017/src/bin/day09.rs @@ -0,0 +1,61 @@ +use std::io::{self, Read}; + +#[derive(Debug, Clone, Copy)] +enum State { + Group, + Garbage, + Ignore, +} + +use self::State::*; + +#[derive(Debug, Clone, Copy)] +struct Machine(State, u32); + +impl Machine { + fn next(self, input: char) -> Self { + match (self.0, input) { + (Ignore, _) => Machine(Garbage, self.1), + (Garbage, '!') => Machine(Ignore, self.1), + (Garbage, '>') => Machine(Group, self.1), + (Garbage, _) => self, + (Group, '<') => Machine(Garbage, self.1), + (Group, '{') => Machine(Group, self.1 + 1), + (Group, '}') => Machine(Group, self.1 - 1), + (Group, ',') => self, + _ => unimplemented!(), + } + } +} + +fn solve1(input: &str) -> u32 { + let mut score = 0; + let mut state = Machine(Group, 0); + for c in input.chars() { + let next = state.next(c); + if next.1 > state.1 { + score += next.1; + } + state = next; + } + score +} + +fn main() { + let mut input = String::new(); + io::stdin().read_to_string(&mut input).unwrap(); + + println!("Part 1: {}", solve1(input.trim())); +} + +#[test] +fn part1() { + assert_eq!(1, solve1("{}")); + assert_eq!(6, solve1("{{{}}}")); + assert_eq!(5, solve1("{{},{}}")); + assert_eq!(16, solve1("{{{},{},{{}}}}")); + assert_eq!(1, solve1("{,,,}")); + assert_eq!(9, solve1("{{},{},{},{}}")); + assert_eq!(9, solve1("{{},{},{},{}}")); + assert_eq!(3, solve1("{{},{},{},{}}")); +} -- cgit 1.4.1