~noelle/aoc-2021

289925eaa5dd54498f9af5eccf4dbd1fa92e25f2 — Noelle Leigh 2 years ago 62b549e
10_1
4 files changed, 145 insertions(+), 0 deletions(-)

A 10/README.md
A 10/example.txt
A 10/input.txt
A 10/puzzle_1.py
A 10/README.md => 10/README.md +3 -0
@@ 0,0 1,3 @@
Day 9: Smoke Basin

https://adventofcode.com/2021/day/9

A 10/example.txt => 10/example.txt +10 -0
@@ 0,0 1,10 @@
[({(<(())[]>[[{[]{<()<>>
[(()[<>])]({[<{<<[]>>(
{([(<{}[<>[]}>{[]{[(<()>
(((({<>}<{<{<>}{[]{[]{}
[[<[([]))<([[{}[[()]]]
[{[{({}]{}}([{[{{{}}([]
{<[[]]>}<{[{[{[]{()[[[]
[<(<(<(<{}))><([]([]()
<{([([[(<>()){}]>(<<{{
<{([{{}}[<[[[<>{}]]]>[]]

A 10/input.txt => 10/input.txt +94 -0
@@ 0,0 1,94 @@
(<[<[((<[<([<<[]()>{{}()}>({<>[]}<[][]>)])<<[{{}[]}[{}<>]]([()<>][()()])>>>]((<{{([]{})<[]<>>}(<[
<[{({[[<{[{{{<<><>><{}>}<([]()){()[]}>}({(()()){{}<>}})}{([<()()>[<><>]><<{}[]>({}<>)>)}]{{[((<>()){<>[]
[[{[[(<((<[<<{{}()}<()[]>>(<<>{}>{{}()})>]<<[[{}()](()<>)][<<>{}><[]()>]>{((<>()){{}()))}>>[{[<[<>{}
{{((({({(<[({<<>()>([]<>)}({()[]}(<>{}))}[({{}{}}([]()))<({}[])[[]()]>]](<{([]<>)(<><>)}{[[]]
[[({[{(((<(<{({}[])}((()<>)([]<>))>({{[]<>}{{}[]}}{[<>[]][()()]})){(<{{}[]}{{}[]}><([][])[<>{}]>)}><<{{{()}[
(<{([{<[([(<({{}{}}{<>()})[<{}<>>{()()}]><((<>}(()<>))>){<[[()[]](()[])]>[{<{}[]>(<>())}]}](<[({(
<{{{<({[{<<[<({}()){[][]}>[<{}{}>[{}<>]]][[(()<>)([][])]]>><{<[(<><>)]>{(<()[]><[]{}>)<<<><>>(<>[]
({{{{<<[{([(({{}{}})<[[]<>]>)])}]>>}[(<[<<<{[{{}()}]<[{}{}]>}>>{(({(<>())<()()>}(<[][]>{()()})))}){[<<([()
<(([{(<{{{{([({}{})(<>[])][[()[]][<>{}]])<[<()[]>]}}{<<{{}<>}><{<>}([][])>>{<{{}{}}<{}<>>><((){})
<(<<[([<[<({{{<>[]}<()[]>}}[([()<>]([]()))(({}<>){[]{}})])>]{({[([<>()])]})}]{[[<(<{()<>}[{}<>]>{[()[]][<><>]
{[[[((<(<[<(<[()()]>)<<<{}<>><<>[]>>(<(){}>)>>](<([<(){}><[]()>](([])))[<{{}{}}{<><>}>{<<>>{<>
[<{([{<[<<<[({[][]}<{}[]>){(()<>)<{}<>>}]><{{{[]<>}<()<>>}[(()[])[{}<>]]}(({<>[]}<{}()>)(<{}[]>([]{}))
{<[<[<<[<[{[{(()<>)}(<<>{}>[<>()])](([<>[]](<>[]))[[[]<>]([]<>)])}]><{{<{{[]<>}{{}[]]}<[<><>
[((<<{<[{<{(<[[]{}]>)}<<({()[]}[[]])<(()<>)[(){}]>>(<[{}<>]{<>[]}>)>>{[<<{()<>}]<[[]<>]({}{})>>[<[(
<<<<{[<(<[[<<{()[]}({}<>)>{{[]<>}{[]()}}>](([{()}]([(){}][<>[]])))]{[(<(()[])[<>[]]>{([]())}){(
({<[({([{[(<[{<>{}}(<>[])][<()()><()<>>]>)]}({<<<{[]{}}[<><>]>>><{((<><>))<<<>[]>{<>[]}}}([(()<>)<<>{
<(<({{[<[{<[[{()[]}]((<>()))]<[[()[]](<><>)][[{}{}]<()>]>>}]>]{<(({<((())[<>{}])[<[]<>>{<>{}}]>}<<{[<>[]]
{[([{((<({<{[{[][]}<[]{}>]{{<>{}}<{}[]>}}>[<{(<>[]){[]{}}}<{[][]}{{}}>>]}{((<[[]()]<[]>>)[[<()[]>
(<{(({[(<{{(({<>[]}[{}])[[()()][[]()]])}[{(<()()>{[]<>})(<(){}><[]()})}[(([]{})<<><>>)<(<>())<<>
<(<{<({<((<{(({}{})><(<>[])>}>[<{<<>{}>([]{})}{[<>{}]([]())}>([[()[]]<{}<>>]({[][]}<()[]>))]){<[(<{}<>
([{({([({([[[{[]{}}({}<>)]]((<{}()><<>{}>){({}[])<{}<>>})]>}{[({{(()<>){<>[]}}[<()[]>[()<>]]}<<<<
{(<<[{(<<<(<<{[]<>}<[]()>><(<>)(()[])>><{(()<>){{}<>}}>)({{(<>())[<>[]]}}<[[{}{}](()())]<{{}()}(
<<(<<{[{([{([[<>()][[]()]](<()<>>[[][]])))<(<<[]<>>>)[({<>[]})]>][<<<(<><>)(<>)>[([]{})]>>])[[{(<(<>()){[]
<<<{[(<(<[(([{{}}]((<><>)[{}<>])))<({{<>{}}[{}<>]})>]{<[<(<><>)[{}{}]>[[{}[]]({}{})]]{<[[]<>
<{(({{{[[[<([{{}[]}]({(){}}((){})))>]]<(({[{<>()}({}{})]})(((<(){}>[(){}])[{[]{}}(<><>)]))
<[[{((<{([(<<{()<>}(()[])><<[][]>>>{(<{}[]>({}<>))})<<<<()()>{[]()}>(<<>()>)>>])}>))}[<<{[<{{{{<[]<>>
({(<{<(([[({{{[]{}}[()<>])}{(((){})<()[]>)})[<([[][]][[]()]){{<>()}[[][]]}>(<(<>)<<>[]>>{[<>[]]{[](
((({(<<({<[[[{<>}[<>()]]<<{}<>>({}[])>]]<({<{}{}>[()[]]}{<{}<>>{<>()}}){[(()())<{}[]>][([]{})[[]<>]]}>>[{[<((
{[[<[([{{<[<[[<>()][{}[]]]{<<>()>{[]()}}>]{[<[<><>]<<>{}>><{<><>}<<>{}>>)[{<{}<>><<>[]>}{{<><>}}]}>{
<(<{(({([<[([([][])(()<>)]{[<><>](()<>)})((([]{})[[]()]))]([({[]()}{<>{}}){{{}})])>]{<<({<<>[]
<<{([{<[{{(({{{}()}{[][]}}<{[]()}{<><>}>){{<()[])<<><>>}[<{}[]><{}[]>]}){<<{[]()}<<><>>>{<{}{}>({}(
<[[<<(<({<([((()<>){()[]})[([][])<{}[]>]]({<<>()>((){})}([[]()]({}<>})))>})[<<{({([]())<<>{}>}{{()
<{(<[[<(<<({(<[][]><<>{}>)[<{}{}>[()<>]]}(({()[]}<{}[]>)))>[<[{(<>{}){()<>]}<[{}[]][<><>]>]>]>[<[({<
(<(([{{[<(<[<{()}{[][]}>]>{(((<>())[{}{}])<[[]]<(){}>))})>](<[(<(<[][]><<>()>){<{}[]>([]{})}>{(([]))<([]<>)[(
{((<{(({({<[{<{}<>><<>[]>}((<>{})[[][]]]]{([()[]](()()))([[]<>]{{}()})}>})(<[<<<[]{}><()[]>><<{}<>><<
{<{(<[<{[[{{{[{}()]}({()()})}((([]<>){()<>})(<<><>>))}<[{{()()}{[]()}}]>]<[((<[]()>((){}))([()()][<>
([({((([<({[[[[]()](()<>)][({}())<<><>>]]}<{<[{}<>][{}{}]>(([]<>){[]()})}[<<[]()>[{}()]>]>)<([([()
<<{({<<[{[<{<(<><>)([])>({{}[]}{[][]})}<([()()])(([]{}))>>([(<[][]>{{}<>})[[<>{}]<()<>>}]{[{{}[]}({}<>)]<[[]<
([<{[[[([[<[(((){})[{}()]){{[]<>}(()<>}}][({(){}}{<>[]})]>]])({<[{<(()<>)>({[]{}}<{}()>)}(([()()]<<><>>
([({{[<([[{<[{()[]}[<>]]({<>()})><{({}[])(()<>)}{(<>{}){{}<>}}>}]])>]<([([[{[[<>{}]{[]{}}]{<[][]]{{}[]}
[[{(({[{{[[[<(()[])[[]<>]>]{<{()[]}{()()}>{(<>[])({}[])}}](<((<><>)[<><>])([<><>])))][[[(<(
[{(<<{(((([[<<{}<>>({}())><<<>[]>[{}{}]>][<(<>[])<{}>>[<[][]>{{}[]}]]]<<(<[][]>{[]()})({{}()}<{}<>>)><([<
{<[[<{{<[[(<{{()()}<[]<>>}><<{<>}<{}{}>><<[][]>>>)<{{[()<>]{{}{}}}<({}[])[(){}]>}>]]>}<<(({{(((){}
((<([[<{{<(<([<>()]{(){}}]({[]()}<()()>)>(([{}[]]((){}))))<[{[<>{}]({}<>)}]>>}[[<({(<>())(<><>)}){([<><>][[][
<[([<(({<(([<({}<>)[()]><<[][]><<>()>>]<{([]{})}<{<>{}}{[]()}>>)){[[{[<>{}][[][]]}]<[[<>()][{}[]]]>][<[[()
((({({[[[[{{<(<><>)((){})>}}]{{[[[<>[]][<>[]]]{{()<>}[[][]]}]{{{{}{}}{<>[]}}([{}][<><>])}}({(
<<<{[<(<({[{[({}[]){()()}]}]}{[(({{}()}[[]<>])[([]<>)(<>)])]{{({()<>}{<><>})<<{}()>>}<[<[]{}>]{([]<
(({[(<<<<{((((<>{}){[]<>})[{[]<>}])(([[][]]<()<>>)<[{}<>]<[]{}>>)){(({()[]}<[][]>)[[<>[]]{()<>}])([[()[]]]<
<([<<[<<[{[[<<[][]>>{((){})[<>[]]}]((<{}{}>[[]<>]){<{}()>(()<>]})]({[(<>{})(<><>)](<(){}>[
((<{[{[[{<<((<<>{}>{<>()}){{[]()}((){})})((([]<>)<<>[]>)<(()){<>[]}>}><[<(<>[])<{}()>>]{<<
[(<[{([{<{([[(()){(){}>]{{{}<>}<[]()>}][(<()<>>[(){}])<[()](()<>)>])}({([[[]{}]({}())]({()<>}{
[<[{[<[{[[<[{([]){{}{}}}]>][[<<(<>{})<<>{}]><{{}()}>>(([{}<>]({}))[(<>{})<[][]>])]]]}]<[(({
(([{{<<{<[[(((<>())<[]{}>)([()()}(()())))[((<>()))<[{}()]({}[])>]](<{{<>}{{}<>}}>)]>[{<{{[
<<[[{<([<<<<{({}<>]([]())}({{}()}<()<>>)>[<<()()>{()()}>({()<>}[{}()])]>{<(<[][]>)>[<[{}{}]>((<>()
(<{[<[({{[[([<[]{}>[[]()]]{{{}[]}(<><>)})]<[([<>{}]<{}[]>)[<{}<>>{[]()}]]<(<<><>>(()()))<[<><>}{{}{}}>>>](
[<((<{{[(<(((<[]()>([][]))(<()<>>{{}[]}))((<{}{}><{}[]>)({{}[]}[[]{}])))<{(<[][]>)<{<>()}>}{{[()<>]}{{<>(
{((([{{((<<<<[()()][(){}]>{[[][]](()<>)}>>{{{{<><>}[[]<>]}[{<><>}({}()]]}([[<>]{(){}}][[(){}](()<>)])}>[([([[
[(({<<{([{(<[<()[]><[]()>]((<>[])[<>()])>([<(){}><<>()>]{[<>()][(){}]}))}[<[{[{}()]{()()}}(<<>>{[]})]{[<<>()>
<[{[<<({<<<[((<>()){()()})[(<>[])([]{})]]><[<([][])([]<>)>(<[]{}>(()()))][{[()[]]{[]<>}}[(<>{})<<>
((<[<[(({[{[[<<>[]]{[]()}]({()<>})]{[<<>()><{}()>]}}(<(([]{}){(){}})>{<{{}()}(()())>})]}([(<{[[][]
{(((((<({[<[{<<><>>{<>[]}}(<(){}><[]()>)]<{<{}()>(<>())}[[[]<>]{{}<>}]>>{[{<()()>[[]()]}[<{}>]]}]{
(({([{<([<{{<<[]{}>[[]{}]>({{}{}}({}<>))}<[{<>{}}{()<>}][<<>{}>]>}>{({(<(){}>[{}()])[{()<>}[()<>]]}<[{[
[[{{[<<[<((<{{{}()}<[]>}{[{}<>]<()[]>}>({[[]{}]}[([]())<[]{}>])){(<<()()>>{[{}[]]<{}{}>})})>]>>]<([<[<
{({{{{[[<{<[{[{}<>]}([[]{}][{}<>])][((()()){[]()}){[<>()](<>())}]>}>[{<[{{<>{}}({}())}[<<>{}>((
({[((<{{<<<({[{}{}][(){}]})((<[]><()()>)<{<>()}[[]<>]>)>(({<{}[]>([][])}(({}{})<<>()>))<{<[
[<<[<{[[{{(<{[[]<>)({}[])}>)}}(({{((<>[])<<><>>)}{[[[]<>]]{{[][]}<{}{}>}}}){[[((<><>)[{}<>])
(({<(<([({<(<<()<>>([]<>)>[([]()><()[]>])<[<()[]>[()()]]{[[][]]{{}[]}}>>{{<<[][]><[]{}>>{[{}[]]<<>>}}{{<[]{
([{{({({{{<([({}[])[()<>]][[[]{}]([]())])>([[[()()][<>()]]([{}[]]{{}()})]<{{[]<>}({}[])}{<()[
(<{(({(<{{[<[[()<>]{<>()}][<(){}><()<>>]>{<<<>[]>[<><>]><({}<>>>}](<<{<>[]}[[]<>]>[[[]<>](()[])]>{{{[]
[[[<[([([(({{<<><>>([][])}})[([[{}()]<<><>>])<({{}<>})<{{}}({}{})>>])])<([((<[[]<>]{(){}}>{[[]<>]<[]<>>})(
(({(<({[[<{<([{}<>]{<>()})([()()](()<>))>(((()())[{}()])({()[]}{{}<>}))}>([({<(){}>([]<>)}{[<>()]<<>>}
({{[<<{<<[<<{[()()]<<>[]>}({[]}<<>{}>)>[<<{}{}>[<>[]]><({}<>)<[]()>>]>({(<()[]>(<>[]))}[([()()][{}]){{()()}{
(<({{([{<[{(([()]<<><>>))}<<<[()][{}{}]><([][])(()())>>[[<<>[]><[]>]{[<>{}]<[][]>}]>](<(<<[]>({}())
(<{<([[[<<((([<>{}]{()[]})([(){}]{{}<>}))[[[{}<>](()[])][[<>[]](<>())]])>>([{([{<><>}<{}[]>]
<{[{[{<{{({<<({}[])><{()()]<[]<>>>><[({}[])[()()]]<[{}<>]{<>{}}>>}((({()[]}{[]<>}){[[]()]([]<>)})))
[(([[[[<<<[<{{<><>}{[]()}}[({}[])<(){}>]>(([[][]]([]{}))<{{}}(()<>)>)]({<<[]{}>{[]<>}>{[()<>}{{}}}}{{[(){}]}
{(([<{<(<{<{{<()><[]{}>}}({{{}<>}}<{<>[]}<{}<>>>)>[<([{}[]]<()<>>)(<{}{}>{()[]})><<{<>[]}(()[])>>]}(
(<((<{[[{({[([()[]]<()<>>)[<<>{}>({}[])]][<[<>[]]><{(){}}>]}[<(({})({}()))(<[]{}>(<><>))>[[([]{})[{}[
{({([[[[{<([<{{}<>}[[][]]><<<>[]><<>{}>>]{{<{}<>><[][]>}({[]{}}<{}[]>)})>{{{{[[][]]}}}}}[<[[{[{}[]][()()]
[{(<([{{{<{<({{}[]}<()<>>){<<>())[{}[]]}>{{{[][]}}[[(){}]{<>()}]}}([(<<>()><[]()>)]{({[]<>}
[<[([{<((({<{{<>{}}}<<(){}><()()>>><({()}[[]{}])(([]())[<>[]])>}))){<[{{{(()[])({}())}{{()()}{{}<>}}}[(<{}
<([({({{(({{({<>}(<><>))}{([{}[]]{{}<>})}}[{({[]<>}([]<>))[<[]>([]{})]}({[[]{}]({}())}{<{}<>
[{(({(({<[[{<[(){}](<>[])>}[[[<>()]][([][])<<>()>]]](((<<><>>[(){}])([[][]]<{}{}>))[<(<>()){[]{}}>[[()[
<<{{<[(([{[{[[<><>][[]()]]<(<>[])[[]<>]>}]<([<()[]>((){})][<{}>(<>())])>}][{(<([()()][<><>])(({
({(<({([(<[<{[{}()]({}{})}<<{}{}>(()<>)>>]>{([<[<><>]<(){}>><({}[])((){})>]{{<[]()>[{}[]]}(({}{})<
<[{<{((<{((<[([]<>)]<{{}()}{()[]}>>(((())){<[]{}>[{}[]]}))<[<<{}[]>((){})>[<()()>{()()}]]<[[(
{{{((<(([{({(({}{})({}{}))}[<{()<>}[{}()]><([]()){[][]}}])[([[()[]][[]{}]])<{({}())[<>{}]}{(<>[])}
<({[{[[{(({<(<<>>[(){}])({[]{}}<[]()>)>}<{[([]())<<>{})]{(()[])<[]>}}(<[{}{}]>(((){}){{}{}}))>)
<{[[({[{[{[([[<>{}]((){})][[[][]]{()<>}])<[<{}()>(<>{})]<<<><>>[<>()]>>][[[<[]<>>{{}<>}]<{[]{}}<[]{}>>]
(({(<((({({{<<{}()>(()<>)><<<>{}>[{}{}]>}(((()<>)(()()))(<{}<>>))}[<[[[]<>]]({[][]}[<>{}])>]){[(({{}{}}){([][
[{{<({<<{(<({<{}<>>[[]<>]}<[{}[]](()()]>)>([{{<>[]}}{([][])([][])}]))({(<{[]{}}{()<>}>([<>()]{[]{}}))
[<({[(<{{{[((<[]<>>(<>[]))([[]<>]<()<>>))(<((){})>)]}}}>{{<([<[<()[]>{{}<>}](([]())[[]<>))>]{(({[][]}<<>(
([(({<([{({<(([]<>)(()[])){<()()>{<>()}}><([[][]]<()<>>)[[[][]]<()<>>]>}[{[{()[]}(<>[])]([<>[]]<<>()>)}])
{{{([<[([{(<[{[]()}<[]{}>]>)}])<<<<({(<>())<{}()>})[{({}[]}{<>[]}}<<[]<>><{}[]>>]><(<[()<>

A 10/puzzle_1.py => 10/puzzle_1.py +38 -0
@@ 0,0 1,38 @@
"""
Solution for AoC 2021 10 Puzzle 1

cat input.txt | python puzzle_1.py
"""
import sys

OPENERS = ("(", "[", "{", "<")
CLOSERS = (")", "]", "}", ">")

PAIR_MAP = dict(zip(OPENERS, CLOSERS))

ERROR_POINTS = {
    ")": 3,
    "]": 57,
    "}": 1197,
    ">": 25137
}

if __name__ == "__main__":
    error_score_total = 0
    for line in sys.stdin:
        stack = []
        for char in line:
            if not stack:
                stack.append(char)
                continue
            if char in OPENERS:
                stack.append(char)
            if char in CLOSERS:
                stack_head = stack[-1]
                expected_closer = PAIR_MAP[stack_head]
                if char != expected_closer:
                    error_score_total += ERROR_POINTS[char]
                    break
                else:
                    stack.pop()
    sys.stdout.write(str(error_score_total))