Day 10 pronounced X
parent
dabcf45f86
commit
909d00d3ed
@ -0,0 +1,4 @@
|
|||||||
|
name = "day10"
|
||||||
|
uuid = "ae02e071-8bc8-4e06-99ae-6edf1bcf85d9"
|
||||||
|
authors = ["HeNine "]
|
||||||
|
version = "0.1.0"
|
@ -0,0 +1,10 @@
|
|||||||
|
[({(<(())[]>[[{[]{<()<>>
|
||||||
|
[(()[<>])]({[<{<<[]>>(
|
||||||
|
{([(<{}[<>[]}>{[]{[(<()>
|
||||||
|
(((({<>}<{<{<>}{[]{[]{}
|
||||||
|
[[<[([]))<([[{}[[()]]]
|
||||||
|
[{[{({}]{}}([{[{{{}}([]
|
||||||
|
{<[[]]>}<{[{[{[]{()[[[]
|
||||||
|
[<(<(<(<{}))><([]([]()
|
||||||
|
<{([([[(<>()){}]>(<<{{
|
||||||
|
<{([{{}}[<[[[<>{}]]]>[]]
|
@ -0,0 +1,106 @@
|
|||||||
|
<{({(([[<<([[([][])]{([]<>)([]<>)}]<[[[]{}]{()[]}]>)(<<[[]()][[]()]><[<>[]]<[]()>>>{<<<><>><<>[]>>[<[]<>><
|
||||||
|
{<[<((<<({([{{{}[]}<<><>>}]<<{[]<>}([]<>)>>)<{(<[]()>{()()})<(()<>){(){}}>}([(()[])<[]>][[[][]]{{}}])
|
||||||
|
<{[[{<[[{(<[[({}())[()()]]([<>()](<>()))][(([]<>)([][]))(({}{})[<><>])]><<<[[]<>][{}[]]>([<>{}
|
||||||
|
<[[<[([({[{<[({}<>)([]<>)](<<>[]>([]()))><[<[]{}>[<><>]]>}>[{[[({}<>)<()<>>][{{}[]}(()())]][[(<>{}){<>{
|
||||||
|
[((<{((([[<<<[<><>]{{}[]}>>(([<><>]<()[]>)<(()<>)>)>([[[{}{}][[][]>]<{<>()}[<>{}]>])]]<{[<[
|
||||||
|
([{([[[{(<({<<[]<>>[()()]>{(()[])}})<(<<{}()>(<>>>([(){}]))<[(<>{}){()}]((()[]){()()})>>>)}{
|
||||||
|
<{{[(<[<<[[{<(()[])>[[{}()]{{}[]}]}[[(<>())[()()]]{<{}{}>}]](<{[<><>]{{}{}}}<({}[])[<><>]>><{[{}<>](<><>)
|
||||||
|
{({<[<([[(({({<>()}{{}{}})})<<<((){})[[]()]><{{}()}[[][]]>>{(<{}{}>{{}()})}>)<<{<[{}[]][{}{}]>([[][]]{
|
||||||
|
{[(((((<{[({<{()[]}(()())>{<(){}>{{}()}}}(<[<>()]{[]()}>(<()()>{{}<>})))[<[[{}{}](<>()>]({[]<>
|
||||||
|
(([((<{<[((<{{<><>}{[]{}}}><<<<>>[{}]>([[]{}]<<>[]>)>)[[{<{}>{()()}}[[{}[]](()()>]](<<<>{}>[[]
|
||||||
|
{<([[{<{([[<([[]<>]({}{})){{{}()}({}[])}>](<(<()()><()[]>)<<[]<>>([]{})>>)]){[{<<[()[]]<<>{}>><({
|
||||||
|
<{[[([<<<(<{{(()<>)(()())}([{}<>]((){}))}>)>({({{{()<>}({}<>)}<[[]<>]{<>[]}>})(({<(){}>[<>[]]}<([]{})<[]{}>>)
|
||||||
|
(<{<{[[({(<[((<>[]){{}})<(<><>)<[]{}>>]((<<>[]><[]()>)<<{}{}>{(){}}>)>(<[[[]<>]]{{<>{}}{[]()}}>(<{
|
||||||
|
{(({{[[{<[((<<()<>>[{}{}]>((()<>){[]()})){{(<>{})[<>[]]}<<<><>>>}){{({<>{}}([]()))[{<><>}{[]
|
||||||
|
(([<(([({{<{[{()<>}<{}[]>]}{[[()()][()<>]}[{<>{}}({}{})]}>((<<<>{}>[<>()]>{{[]<>}({}{})}){[<{
|
||||||
|
[[{{(<<[[[[<<<<>{}>({}())>[([]<>)(()())]>]<<<{<>()}>[<<>[]>[()()]]>[([[]()]<[][]))<[<>{}]{{}<>
|
||||||
|
{[{(((([<[{([(()()){()()}][<(){}>[{}<>)])[(<{}<>>{<>()})({{}<>}[()[]])]}(<({[]<>}<()[]>)({[]<>
|
||||||
|
<<([(([{<{<<<[{}[]]((){})>((<>[])(()<>))>{{{<>()}{[]}}{([][])}}>[<{{<>[]}<<>>}({[]<>})>]]({({{<><>
|
||||||
|
[{((<{<[[<[{[{{}<>}]{[{}][<>[]]}}[<([]())<()[]>>((<>){[]{}})]]<{(<()<>><{}<>]){[[]<>]({}{})}}({<{}[]>{{}
|
||||||
|
<[<{(<[[<(((<({}[])><(<><>)(<>())]){{{()()}(<>())}<[{}()]>})[([[<>[]]{{}[]}]{{{}()}<{}[]>})[[(()<>){<>
|
||||||
|
[([{{[<([{[([[()<>]])([[<>][()[]]][[<>[]]<<>[]>])]}{([<<{}()>({})>(<[]()>(<><>))]<<{{}<>}{<>}><(<>
|
||||||
|
<<[[([([(<(<<[{}[]]<()[]]><{[]{}}[<>()]>>)>[<<({[][]}<<><>>)[<{}{}>{()<>}]><({<>{}}([]))((
|
||||||
|
<({<{(<[({([[{()}(<><>)](<[][]>[{}{}])](([[]<>]<<>{}>))){({<<>{}>[[]{}]}<([][])>)<<(<><>)<[]<>>}>}}((([[()<
|
||||||
|
{([<(<[(({[({[(){}]<<>{}>}[[{}{}][{}[]]])]{({[()<>]{()[]}}(<[][]>[()[]])){{{[]{}}(<>[])}[<(){}>(
|
||||||
|
<[<[<{[{<[{[<<{}<>>(<>)>]{<({}{}){(){}}>((<>{})[{}<>])}}[<[[<><>]{{}<>}]{<()()>}>{<<[]()>(()())>{{{}<
|
||||||
|
(({[[<<[({[{{<()()>}}{<[<>()]>}][(<{[][]}>{[{}()]{[]<>}})<{{<>{}}(()[])}{{[]()}<<>[]>}>]})
|
||||||
|
<((<([[({(<{[[(){}]<[][]>]}>({<[()<>](()[])>(([]<>)([]<>))}<{[[]<>]{(){}}}(<()<>>([][]])>))}<{[<[({}
|
||||||
|
{({{{[[{{[{(<<(){}>[{}{}]>((()<>)[<>{}]))[<<{}[]><[]>>[{{}{}}(<>[])]]}[(<<(){}>({}{}))((<>{})([]<>)))
|
||||||
|
[[(({[{(<({[{<[]()>{()[]}}<(<>())<()()>>]<(({}[]){{}<>])((()<>){{}[]})>}([[({}{})[<>()]][{<><>}]]{([[
|
||||||
|
[[{<[([<[((<([[]{}][{}<>])([{}<>])>[([()<>]{{}{}}){{[]()}}])<({{[]()}[[]()]))>)([<<<<>{}><{}()>><(<>
|
||||||
|
<<({{{<{[<{<{<[]<>>[[]{}]}[<[]()>{[]{}}]>[[[(){}][<><>]]{(<>[]}({}{})}]}><[[({{}[]}{[]()}){(<>())[()<
|
||||||
|
{{(({[[[{<[<(([]())([]{}))([{}{}](()[])}>]>}([<{[[[]()][(){}]]<{<>[]}>}({<()<>><[]<>>})>((([()
|
||||||
|
(<(({{(([(({{<{}[]>({}())}([<>[]][{}()])}((<[][]>{()<>}){[[]<>]<{}{}>}))<({{[]<>}([][])}{<[]{}>{<>[]}})
|
||||||
|
((([<([([{{{<<<>{}><{}[]>>[[<>[]][{}[]]]}}(([<<>{}>[()[]]][{{}{}}])(<[()()][<><>]>{{<>[]}})}}]<{[[<
|
||||||
|
{{(<[<[<[<<[[(<>[])]({<><>}[()()])]>>]>[{{[[{(<>[])([][])}{[[][]]([]())}]>[[[<{}{}>({}())]<{<>
|
||||||
|
<[{[[([[{[(<[<{}{}>{(){}}][{[]<>}<()[]]]>(([()<>][[][]]){[<>{}](()[])}))[[<<{}>[<>{}]>[({}{})({}{})]]<([[]{}
|
||||||
|
({<<<{<({{{{{[()()]({}())}[[[]{}][<><>])}({<()()><[]()>}({<>()}))}{(((<>()){()()}){<(){}><()[]>})(([{}()]
|
||||||
|
([<({[{({(<<{[{}()]}{{{}[]}((){})}>>)<<{[((){})[()]]}<<{[]<>}<<>()>>([<>()][[]<>])>>{<<[<>[]]<[]<>>)<{<
|
||||||
|
(<[<<(<[[[[{{({}<>)[{}{}]}<[[]{}]([]<>)>}][<[<<>{}>{[]}][[[]{}](<>())]><<[<>()][(){}]><{[]
|
||||||
|
(({[[(([<(([{({}[])[<>{}]}{(<>[])({}{})})<<<{}[]>({}())>[({}<>)<{}()>]>)[<<[[][]]((){})><{{}(
|
||||||
|
{[((<([<[{[{<[<><>][()()]><{<>{}}>}[{<[][]>[()<>]}<(<>())<()<>>>]]<<<(<>())<()[]>>>[{{{}[]}}[[{}()]((){
|
||||||
|
{{<{({{({[<((({}{}){<>[]}){<{}()>{<>[]}})>(<{<<>{}><[]<>>}>[[{[]<>>{<><>}]{((){})<(){}>}])]}(<{[{{<><>}{[
|
||||||
|
(({<[[{[(<(((({}{}){()<>}))<{{[]{}}{{}{}}}<[{}<>][(){}]>>)>[{{(<<><>>([]{}))[((){})<{}[]>]}}(([[<>()]{<>()}]
|
||||||
|
[<([[[<[<{<{<{[]{}}{[]{}}>[([]())<<>[]>]}({{[]{}}<[]()>}<({}())(<>{})>)>}[({[[{}[]][{}<>]]})]>]><[
|
||||||
|
<{[<<[[<{[[{<<{}[]>[<><>]>}({[[]{}]<{}()>}((()[])))]{[<{()}[[]{}]>]{(({}[])<{}()>)<(<>())[()<>]
|
||||||
|
[[([[{[[(([{[[<>()]{<>()}]({(){}}({}{}))}[<[<><>]([]())>(<[]()><{}[]>)]]{(<<<><>>[[]{}]>(<[][]>((){}))
|
||||||
|
{(<<[[{[{{(<<<{}[]>(<>[])>({[]{}}([]{}))>[{<<>()>[[]<>]]([{}[]])])}[[{(<<><>>[()()])<<<><>>>}([<<>
|
||||||
|
([((<(<[(<{((<{}{}>{<><>})){{(()[])[{}[]]}}}{[[[(){}][<><>]]]({<()<>>{{}[]}}<[()()]{()[]}>)}>[<{(<{}
|
||||||
|
[(<[([[({({<[{<>()}([]<>)][(<><>)<()[]>]>})[{([(())({}[])][{[]<>}<()<>>])}({<[{}{}](()())><({}())[<>[]
|
||||||
|
([(<<[<{<{((<(<>[])({}<>)>{{()()}<<>{}>}))<{[[()[]][()[]]][({}[])<{}()>]}{<({})><{[][]}{{}<>}>}>}<<<({(){}}
|
||||||
|
[(<{(([({<{{(<[]<>>({}()))}}[<[[{}[]][[]]]>[({[]<>}(<>{}))]]>})]<([(<([[()()][[][]]]<((){}
|
||||||
|
((({([(<<{{<<({}())(())>([<>()]<()()>)>}}<[(<{{}[]}<()<>>><({}{}){(){}}>)][(({()<>}([]()))([()]))({{{}()}
|
||||||
|
{<(({[<([{[({([][])[[]{}]}<({}<>)<<>()>>)<<{<>()}{[]<>}>{{{}}{[]()}}>]}])<<{<(([[]{}]<<>[]>)){<<[]<>>><<()[
|
||||||
|
[{<(<<<((<<<{[()<>]{[]<>}}>[[<{}{}>[()[]]]<(<><>)[()[]]>]>{[[[[]()][<>[]]]]({(<>}{[]{}}})}>){({
|
||||||
|
<<[((<<[{{[(<[<>()]><{{}[]}{<>{}}>){[(()[])([]())][[(){}][{}[]]]}]([<[[][]]{(){}}><<{}{}>{<>{}}>][[
|
||||||
|
{<<{<<{<({[[([<>{}])[{[]<>}{{}[]}]][[<()<>>[<>{}]]]]<([{[]()}({}{})]({[]()}{<>()})){[({}<>)[[]{}
|
||||||
|
{<<[{((([<([[<[]()><<><>>][{()<>}<[][]>]]{<[{}[]][()[]]>[{<>{}>{[]}]}){[([[]{}]<()[]>)[[<>()][{}[]]
|
||||||
|
({{{{<([[((({{{}{}}<()[]>}{<()<>>{{}<>}})(<({}{})>({<>{}}[[]()]))){(<<<><>><()[]>>[{()()}{[]<>}
|
||||||
|
({<{[[{({{[<[{[][]}<[][]>]{(<><>)}>([[<>{}][<>{}]]({[]{}}<<>[]>))]}{[({[[]]{()[]}}{(<>{})[()()]})(<{(
|
||||||
|
[{<<<[(<(<{((([]{}))[{<>()}[()[]]]){{<{}{}>}[<[]<>>{<>{}}]}}<(<[<>[]][()()]>)<([{}()]{{}[]})
|
||||||
|
{{(([[([((<([[<><>]])>({[{()<>}<[]{}>]}<{[()()]<{}>}(<{}<>>({}{}))>))[{{([()()]<{}<>>){(<>{})(
|
||||||
|
([(<{[[{<{{<{([]())(<>[])}{{[]<>}{()<>}}>{{{()}}[<[]{}><{}<>>]}}<{[{()()}]{{<>[]}[<><>]}}<<{<>(
|
||||||
|
([[{[{[{<<(<{<{}{}>{[]}}{[{}{}]{()[]}}>[{({}[])}<[()[]]>])>>[(<<({<>{}}{[]{}})>>(<[([]()){()<>}]((()())([]
|
||||||
|
(({<({<([(({<<<>()>([]())>{<()[]>{[]<>}}}(<{{}<>}[()()]>({{}<>}[{}()]))))]){{<[{[(<>[]){()
|
||||||
|
([[(<{[[{<[<(<[]()>[{}[]]){[<><>]{<>[]}}>{{([]()){[]{}}}<((){})([]<>)>}]<<<{{}[]}[()]>(<{}><[][]>)>>>}
|
||||||
|
{{(<[{[([<<<[<{}<>>(<>{})]<({}[])[<>[]]>>({<{}{}><[]{}>}<<[]><(){}>>)>>(((({()()}[[]{}]))<[{[]<>)<[]()>]
|
||||||
|
(({{<<[{([[({[[]{}]{()<>}}[(<><>)[()()]])[<[<>[]]><([]{})[[][]]>]](<((<><>)<<>()>)[([][])((){})]>[(
|
||||||
|
((<<([[<{[{({<(){}><[][]>}{(()[])({}[])})({[{}()]({}{})}(<(){}>(<><>)))}{{[{()<>}<{}{}>][{[]{}}(()
|
||||||
|
<{(((([<[((({{{}<>}[[]<>]}<[{}<>]>)[<({}{})>{{[]()}<{}()>}])<([<<>>(<><>)]((()())(<>{})))>){(({(
|
||||||
|
<{{<<{{{[({{[<()[]>(()[])]}<<[[]<>][[]]>>}[<[({})<<>[]>][[[]]([][])]>])]}}(<({[[<[(){}]>{<[]{}>}]{(({
|
||||||
|
[([[(({([{{({{()}[{}<>]}{({}<>){{}()}}]}}{[<<({}())<(){}>>[{()[]}([]{})]>]{<<{{}()}(<>[])>{[(
|
||||||
|
[{[{[([<<((<<{()<>}<<>()>>[{[]{}}{{}[]}]>[[{[][]}{{}}]])(([((){})(()())]{[(){}]{()}})))}{(<<<<<><>>({}[]
|
||||||
|
<[{({[({[({{(<[]()>{{}<>}){{{}<>}[(){}]}}(([{}()]<[][]>)[[<>]({}{})])}<<[(<>)({})]<<()[]><
|
||||||
|
[((([<(({<<({{{}()}({}<>)}({()[]}[{}{}]))>{[{(<>[])}{(<>[])<{}[]>}]{<[<><>][()[]]>}}>({<{<<>()><<><>>}([{}[]]
|
||||||
|
{({((<<([((<[[()[]]{[][]}]<{(){}}{<>{}}>>({[(){}][<>]})))(<(({<>[]}<(){}>)(<()[]><{}()>))>)]){
|
||||||
|
<{<[<(<{<[({{{{}<>}<<>{}>}{[[]()][{}{}]}}[({<><>}{<>{}})[[{}()]{[]()}]])({{<[])(<>[])}})](<<[[<><>]](<{}{}>
|
||||||
|
[([[[{[((<<(<<()()>>)><<{([]()){<>{}}}<{[]{}}<()()>>>[(<<><>>[()[]]){((){})([]{})}]>>({[<[<><>]{<><
|
||||||
|
<{{({{{[<{[{{{()<>}[<><>]}[(()[]){[]{}}]}(<{{}[]}[<>[]]><{{}{}}<{}[]>>)]{(({(){}}<<>{}>)[<<><>>[{}
|
||||||
|
[[([[{[({[{[({{}[]}{()[]})[<()()>{{}{}}]][(([]<>)<[][]>)[<{}{}><{}()>]]}][<([([][]){()()}][[{}{}]{()<
|
||||||
|
{(<<(((<((((<{()<>}<<>[]>)[<[][]>[{}()]]){[[[]<>]<(){}>][<()<>>{{}<>}]})))<[{{[{{}{}}<[]<>>]}}(
|
||||||
|
{[(<{[<{{({[{[<><>](<>{})}{({}[])(<>{})}]}({<({}[])<[]<>>>(({}[]))}[<<()><<>>}[{()[]}{[][]}]])){[({<<>()>(
|
||||||
|
<([{[(<(<<([((()())<{}{}>)]<{(<>())(<>()]}{[()<>](<>())}>)<[[<[][]>]{{()}<<><>>}](({()()}[[
|
||||||
|
<[<[<{{{[{((<(()()){{}<>)><[[]()](()<>)>))({[[<>{}]{{}()}]({()<>}(()[]))})}]}([{((({{}()}[()<
|
||||||
|
[{([({[<(<{[{[<>[]][<>()]}([[]{}](()()))){{[()()]<(){}>}({()[]}<[]()>)}}<{[(<>[]){()<>}][[()<>]{()[]}]}{<(<>
|
||||||
|
{((<(<({{([{[([]<>){[]<>}](<[]<>>[[]<>])}{{<[][]><()[]>}({()<>}<<>{}>)}]<[<[<>()]([]{})><{{}<>}<{}<>>>][(
|
||||||
|
{<<([<(<{[[{{{<>[]}[[]<>]}{[{}[]]]}{<[(){}]>{[{}()]{[]<>}}}](<{[[]<>]{<>[]}}<<()<>>[[]()]>>)]<[{{<{}>[{}]}<(
|
||||||
|
[[{{{<{[{({<<<[]{}>[()<>]><[[]<>]([]<>)>><{<<>()>[<>{}]}>}((<[{}{}]{[]}]{<[]<>>{<>{}}})[([<>(
|
||||||
|
[[{<<{{[(([[[{()[]}][[()[]]<[]>]]({{{}}})][({([][])[{}{}]}<[(){}]<()[]>>){<{[]{}}[(){}]><{{}{}}<<>()>]}]))<<
|
||||||
|
[(({[<<{<({<([<><>])[{<>()>{{}[]}]>((<()<>><{}<>>)[{[][]}([]{})])})<{{([[]<>]<{}<>>)([()[]]{()()}
|
||||||
|
[([(({(<[<[<((<>{})[[]<>]){[<><>]({}[]>}>]>]>)}[(({(<<[{(){}}[()[]]]>[<(<>{}){{}{}}>[[()<>][()]]]>)
|
||||||
|
{<{{<({<{((<{({})<<>{}>}((()){()<>})>))}((<{((()[]){{}[]})[<<>>[[]<>]]}(([<>](()<>)))><{{{<>()}((){}}}((
|
||||||
|
<[<{<((({{[<{{[][]}}<([]<>)(<>{})>>]}[(([{()()}{<>()}])[<[()[]][()[]]>]){<<[<>()](<>{})>{{(){}}(<>
|
||||||
|
(([{([{[<(<(((()<>))[(())(<>{})])([[{}<>]{{}[]}][{<><>}[{}{}]])>[(([()[]]<[][]>)[{{}[]}(()[])])(([{}{}]
|
||||||
|
{<(<<{<[{<{<<<<>[]>[[]<>]){[[]()][<><>]}>({(<><>)(()<>)})}>[<([{{}{}}<[]<>>])({{[]<>}({}[])})>]}{<<[(
|
||||||
|
<{([({{{<{[{(([]())<<><>>)<[()()]((){})>}]}(<{(<(){}>(<>()))}([[()[]][(){}]](<<>{}>[{}()])}>)>([{<(
|
||||||
|
((([{<<[{{[(<<[]<>>(<>())>{({}{})<{}[]>})[[<()()>[<>[]]][<{}[]>(()())]]]}}]>>)]{{{{[[{[[[([]<>){
|
||||||
|
({(<{{({[[{<<(()[])[()]>[{<><>}{<>[]}]>{<{<><>}{()[]}>{[{}()]{[][]}}}}{<<{[]<>}(<><>)>{{[]{}}[
|
||||||
|
(<[{{(([<{{(<[<>()]((){})>{<{}[]>({}())})}}>][<[{{([{}[]])<([]<>)<<>{}>>}}{<({[][]}(()()))(<<>()>{
|
||||||
|
(<<{{{((<{({<<{}()><{}{}>><<()[]>[<>[]]>>(<[(){}]([]<>)>[({}<>)]))(({{[]<>}<()<>>}[<()[]>(()[])]){<[
|
||||||
|
<[(((<({([({{[[]()]{[]()}}([{}()]<[]<>>)}[[<()[]>{{}{}}]([<>]<<>()>)]){[((()<>){<>[]}){[{}[]){[
|
||||||
|
(({[[({{{[{{({(){}}{{}[]})<({}[])([]<>)>}[[(<>{})]<([]()){{}()}>]}[{<{[]<>}<()()>>([{}<>]<{
|
||||||
|
<[({{[<[{({[({[]<>}{{}[]})[{[][]}{[][]}]][[<{}[]>{[]()}]([()[]]({}<>))]}{<{[{}<>]<[]()>}<<[]()>[<>{}]>><((
|
||||||
|
[{[{<{{[<<[[<<{}<>>>][{{{}[]}({}())}]]([{<<><>>({}{})}{{[]<>}}]{{{[]()}([]<>)}})><({{<[][]>}}){<{{()><()>}>[<
|
||||||
|
{{({([<({(<[({{}{}}<[]{}>)]>[(((<>()){<>()]))[<({}[])(<>{})>{<<><>>{[]()}}]]){{[<(()[])<()<>>>(<()<>>)]([<{}
|
||||||
|
[({[<(<<[{<({<{}()>{{}()}})({({})<()()>}[{[]<>}[{}{}]})><[(({}{}))(((){})[[][]])]>}<{([<[]<>>]<[{}[]]((
|
||||||
|
[<{{{<<(<[[{<([][]){<>}>}{<[[]]{[]{}}><{<>{}}>}]<<{([]())[<>[]]}><(([]{}){[]<>})[(<>())({}<>}]>>](
|
@ -0,0 +1,60 @@
|
|||||||
|
using Printf
|
||||||
|
using Statistics
|
||||||
|
|
||||||
|
include("../../AoC2021.jl")
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
function validateline(line)
|
||||||
|
stack = []
|
||||||
|
|
||||||
|
opening = ["(", "[", "{", "<"]
|
||||||
|
closing = [")", "]", "}", ">"]
|
||||||
|
|
||||||
|
for (i, char) in enumerate(split(line, ""))
|
||||||
|
if char ∈ ["(", "[", "{", "<"]
|
||||||
|
push!(stack, char)
|
||||||
|
elseif char ∈ [")", "]", "}", ">"]
|
||||||
|
if stack[end] != opening[closing.==char][1]
|
||||||
|
return (i, char, stack)
|
||||||
|
else
|
||||||
|
pop!(stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
(missing, missing, stack)
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
function task0(file)
|
||||||
|
|
||||||
|
map(eachline(file)) do line
|
||||||
|
(_, char, _) = validateline(line)
|
||||||
|
([")", "]", "}", ">"] .== char)' * [3, 57, 1197, 25137]
|
||||||
|
end |> skipmissing |> sum
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
verify(10, 1, 0, 26397)
|
||||||
|
verify(10, 1, 1, 316851)
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
function task1(file)
|
||||||
|
map(eachline(file)) do line
|
||||||
|
(_, char, stack) = validateline(line)
|
||||||
|
if char !== missing
|
||||||
|
missing
|
||||||
|
else
|
||||||
|
foldr((c, x) -> 5x + (["(", "[", "{", "<"] .== c)' * collect(1:4), stack, init = 0)
|
||||||
|
end
|
||||||
|
end |> skipmissing |> median |> Base.Fix1(convert, Int)
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
verify(10, 2, 0, 288957)
|
||||||
|
verify(10, 2, 1, 2182912364)
|
Loading…
Reference in New Issue