From 353b229fbdd3ceb01d4cc5df9dd76f9597c12d76 Mon Sep 17 00:00:00 2001 From: Luna Lailatova Date: Sun, 12 Dec 2021 18:26:32 +0100 Subject: [PATCH] day 12 --- day10.py | 48 +++++++++++++++++++++++ day11-2.py | 89 ++++++++++++++++++++++++++++++++++++++++++ day11.py | 83 ++++++++++++++++++++++++++++++++++++++++ day12.py | 32 ++++++++++++++++ input10.txt | 102 +++++++++++++++++++++++++++++++++++++++++++++++++ input11.txt | 10 +++++ input12.txt | 21 ++++++++++ testdata10.txt | 10 +++++ testdata12.txt | 7 ++++ 9 files changed, 402 insertions(+) create mode 100644 day10.py create mode 100644 day11-2.py create mode 100644 day11.py create mode 100644 day12.py create mode 100644 input10.txt create mode 100644 input11.txt create mode 100644 input12.txt create mode 100644 testdata10.txt create mode 100644 testdata12.txt diff --git a/day10.py b/day10.py new file mode 100644 index 0000000..6c10eef --- /dev/null +++ b/day10.py @@ -0,0 +1,48 @@ +import sys + +class lines: + def __init__(self, inp): + self.line = inp + def solve(self): + counter = True + counter2 = 0 + operators = ['()', '[]', '<>', '{}'] + scores = [('(]', 57), ('(}', 1197), ('(>', 25137), ('[)', 3), ('[}', 1197), ('[>', 25137), ('{)', 3), ('{]', 57), ('{>', 25137), ('<)', 3), ('<]', 57), ('<}', 1197)] + scores2 = [('(', 1), ('[', 2), ('{', 3), ('<', 4)] + while counter: + counter = False + for i in operators: + if i in self.line: + self.line = self.line.replace(i, '') + counter = True + for i in scores: + if i[0] in self.line: + return i[1], None + for i in range(len(self.line)-1, -1, -1): + counter2 = counter2*5 + for f in scores2: + if self.line[i] == f [0]: + counter2 += f[1] + return 0, counter2 + + + + +inp = [] +solution = 0 +solution2 = [] + +with open(sys.argv[1], 'r') as f: + for i in f.readlines(): + i = i.strip() + inp.append(lines(i)) + +for f in inp: + tem1, temp2 = f.solve() + solution += tem1 + if temp2 is not None: + solution2.append(temp2) +solution2 = sorted(solution2) +temp3 = len(solution2) // 2 +print(solution2[temp3]) +print(solution) \ No newline at end of file diff --git a/day11-2.py b/day11-2.py new file mode 100644 index 0000000..43979eb --- /dev/null +++ b/day11-2.py @@ -0,0 +1,89 @@ +import sys + +class octopie: + def __init__(self): + self.temp = [] + + def format(self): + self.y = [] + temp2 = [] + for i in self.temp: + temp2 = [] + temp = list(i) + for t in temp: + t = int(t) + temp2.append(t) + self.y.append(temp2) + + def tick(self): + for i in range(len(self.y)): + for t in range(len(self.y[i])): + self.y[i][t] += 1 + + def flash(self): + pas = True + counter = 0 + while pas: + pas = False + for i in range(len(self.y)): + for t in range(len(self.y[i])): + if self.y[i][t] > 9: + self.y[i][t] = 0 + pas = True + counter += 1 + if t == 0: + pass + elif self.y[i][t - 1] != 0: + self.y[i][t - 1] += 1 + if t == len(self.y[i]) - 1: + pass + elif self.y[i][t + 1] != 0: + self.y[i][t + 1] += 1 + if i == 0: + pass + elif self.y[i - 1][t] != 0: + self.y[i - 1][t] += 1 + if i == len(self.y) - 1: + pass + elif self.y[i + 1][t] != 0: + self.y[i + 1][t] += 1 + if t == 0 or i == 0: + pass + elif self.y[i - 1][t - 1] != 0: + self.y[i - 1][t - 1] += 1 + if t == len(self.y[i]) - 1 or i == 0: + pass + elif self.y[i - 1][t + 1] != 0: + self.y[i - 1][t + 1] += 1 + if t == 0 or i == len(self.y) - 1: + pass + elif self.y[i + 1][t - 1] != 0: + self.y[i + 1][t - 1] += 1 + if t == len(self.y[i]) - 1 or i == len(self.y) - 1: + pass + elif self.y[i + 1][t + 1] != 0: + self.y[i + 1][t + 1] += 1 + return counter + + + +octo = octopie() +solution = 0 +passs = True + +with open(sys.argv[1], 'r') as f: + for i in f.readlines(): + i = i.strip() + octo.temp.append(i) +octo.format() + +octocount = len(octo.y) * len(octo.y[0]) + +while passs: + octo.tick() + checker = octo.flash() + solution += 1 + if checker == octocount: + passs = False + +print(solution) \ No newline at end of file diff --git a/day11.py b/day11.py new file mode 100644 index 0000000..e03d0df --- /dev/null +++ b/day11.py @@ -0,0 +1,83 @@ +import sys + +class octopie: + def __init__(self): + self.temp = [] + + def format(self): + self.y = [] + temp2 = [] + for i in self.temp: + temp2 = [] + temp = list(i) + for t in temp: + t = int(t) + temp2.append(t) + self.y.append(temp2) + + def tick(self): + for i in range(len(self.y)): + for t in range(len(self.y[i])): + self.y[i][t] += 1 + + def flash(self): + pas = True + counter = 0 + while pas: + pas = False + for i in range(len(self.y)): + for t in range(len(self.y[i])): + if self.y[i][t] > 9: + self.y[i][t] = 0 + pas = True + counter += 1 + if t == 0: + pass + elif self.y[i][t - 1] != 0: + self.y[i][t - 1] += 1 + if t == len(self.y[i]) - 1: + pass + elif self.y[i][t + 1] != 0: + self.y[i][t + 1] += 1 + if i == 0: + pass + elif self.y[i - 1][t] != 0: + self.y[i - 1][t] += 1 + if i == len(self.y) - 1: + pass + elif self.y[i + 1][t] != 0: + self.y[i + 1][t] += 1 + if t == 0 or i == 0: + pass + elif self.y[i - 1][t - 1] != 0: + self.y[i - 1][t - 1] += 1 + if t == len(self.y[i]) - 1 or i == 0: + pass + elif self.y[i - 1][t + 1] != 0: + self.y[i - 1][t + 1] += 1 + if t == 0 or i == len(self.y) - 1: + pass + elif self.y[i + 1][t - 1] != 0: + self.y[i + 1][t - 1] += 1 + if t == len(self.y[i]) - 1 or i == len(self.y) - 1: + pass + elif self.y[i + 1][t + 1] != 0: + self.y[i + 1][t + 1] += 1 + return counter + + + +octo = octopie() +solution = 0 + +with open(sys.argv[1], 'r') as f: + for i in f.readlines(): + i = i.strip() + octo.temp.append(i) +octo.format() + +for i in range(100): + octo.tick() + solution += octo.flash() + +print(solution) \ No newline at end of file diff --git a/day12.py b/day12.py new file mode 100644 index 0000000..d37dd1c --- /dev/null +++ b/day12.py @@ -0,0 +1,32 @@ +import sys + +inp = {} +solutions = [] + +def juzgfvzgv(poi, path, twice): + nex = inp[poi] + #print(nex) + for i in nex: + if i == 'end': + solutions.append(path + [i]) + continue + elif i.islower() and i in path: + if twice and i != 'start': + juzgfvzgv(i, path + [i], False) + else: + continue + else: + juzgfvzgv(i, path + [i], twice) + +with open(sys.argv[1], 'r') as f: + for i in f.readlines(): + i = i.strip() + temp1, temp2 = i.split('-', 1) + inp.setdefault(temp1, list()).append(temp2) + inp.setdefault(temp2, list()).append(temp1) + +juzgfvzgv('start', ['start'], True) +for i in solutions: + print(i) +print(len(solutions)) + diff --git a/input10.txt b/input10.txt new file mode 100644 index 0000000..dc4a12a --- /dev/null +++ b/input10.txt @@ -0,0 +1,102 @@ +{([[[(<<[{[[[[(){}][()]][({}())]]]<{((<>[]){[]<>})({()()}(<>[]))}<{{{}()}{[]()}}>>})[<(<[[<><>][{}{ +([(<(((<[({{({(){}}<{}()>)((<>{})[{}<>})}}[{[(<>())[[]]]{{[][]}(<><>)}}{<<{}()>([]())>([<>][{}])}])](<[{[ +{{[[<[<(<<<{((<>[])([]<>))(<{}><()[]>)}[(((){}){<>[]})<{(){}}<<>[]>>]>{[{{<>{}}<()<>>}<<<>[]>([]<>)>][ +<[{<(({([[([({{}[]}{<><>})<<[]{}>>]<<<{}{}>((){})><{{}()}<{}[]>>>)](([<([]{})<{}<>>>(<[][]>{()()}) +{{<(([<[[{<{({{}<>}({}()))<[<>[]](<>[])>}><[(((){})){[()]<<>[]>}][{{<><>}(<>{})}<<()[]>({}())>]>}<[{[(()<>) +[<{{{({{[<([<{<><>}{<>{}}><<[][]>[{}<>]>]({<[]{}>[[]{}]}{([]())([][])})){<{[[][]]([]())}>([[[ +{[<[<<([[<(<<<<>>({})>><({(){}}(<>{}))[{()()}(()[])]>}[<({[]})<[()[]](<>{})>>[<({}{})[()<>]><{(){}}>]]> +[(<({{<[{<(<((<><>)<[]<>>)({<><>}<<>()>)><<<()<>>[()()]>{<<>{}>[()<>]}>){{[([]{})<<><>>]([< +<<{{<{<{([{(<{<><>}>((()[])<<>{}>))({<{}>}<[[]()][<><>]>)}<{([[]()]{<>{}})}{(<<>()>{<>{}})[{<><>}{<><>}]}>] +{(<{<({{([[{<({})[()()]><[{}<>][{}[]]>}<<<[]{}>[<>()]>({{}{}}[{}[]])>]<({[[][]]({}())}[(()[]](< +<[<{[<<[(((<([()()]<()()>]([()[]][{}{}])>)[[[{<>}[<>[]]]][(<()()><<>>)<<{}{}>{<>}>]])([(<({}<>)[()()]> +(<<{{([<[<[<[{[]()}[{}<>]]<(<>[])[{}]>><[{()[]}[()[]]]<([]<>)(()())>>]{{{{()<>}{()()}}[(<>< +<[([(<[[[(<[(<{}()>{()()})<<()[]>{(){}}>]><<({[]<>}<{}{}>)[{[][]}{[]{}}]>{<{()()}(()[])>{[<><> +[[([[({{{[[(<<()()>[<>[]]>)<[<<>{}>]([[]()][(){}])>]<(<{()<>}[[][]]>(([]{})[[]()]))[<({}[]) +<<{[({<[[[[[{<<>()>{<>{}}}[<()()>]](<<{}<>>{{}<>]><[{}<>]<()<>>>)][((<[]{}>[[]])<{{}()}>)[((<>{}))<<<>{}>( +[[<[[<<(({{<({[]<>}([][]))>{([[]()]{{}<>}){[[]{}][()<>]}}}({{({}()}[[][]]}(((){}){<>})}(<[{}<>]{()()}> +{[{<[[(({<({[{()[]}[[][]]]}(({<><>}<{}[]>)))>}{[{(<{[]{}}{{}[]}>{<<><>>})}<{{[[][]]{<>()>}}<{ +{[({<{<{[[([[<()<>}{[]<>}][<<>[]>([])]])]([({{[]()}({}())}([<>()](<><>)))])]{{<[<<[]<>>(()())>(<<>()>{<> +({([<({((<({<<()<>>[(){}]>[(<>{}){<>[]}]}){([{{}[]}])([({}()){<><>}]{[<><>]([]())))}><<[([{}[]])]( +<{[{<{<<[<<<[(()<>){[][]}]([()<>]({}{}))>{(<{}{}>[<>{}])[{{}()}[(){}]]}><({<[]<>>[<>{}]}{([]<>)<[]{})})<([{}( +<[<<(({<[{{(<[[]<>]<<>()>>([{}<>]{[]()}))}{<(([]<>)<()<>>)[({}[])<[]{}>]><<<{}[]>{{}<>}>({<>[]}[(){}])>}}<( +[[[[[[(((<{<{(()())<<>{}>}>(<[<><>]({}[])})}{{<[()<>]<[]{}>>[{{}<>}[[]()]]}({<<>[]>}[<{}<> +[(({{<{[<[[(<(()())<<>()>>[<<><>><()()>])(<[{}()]><{[]()}<{}{}>>)][<[({}())<{}<>>][({}[])(()[])]>((( +(([<({{<{{[<<{[]()>(<>{})>[[{}]{{}{}}]>{<<[]{}>>[([][])[<><>]]}]<<[<<>[]>({}<>)]({<>[]}<{}{}>)>[{<{}<>>{[]()} +{(<<[{<<{({(<(<>{})(()())><(<>[]){[]<>}>){[(<>[]){[]()}]{[<>()][{}<>]]}}{([[{}()]]((<><>)))[([{}()]([]())) +[{({[[{{[<<{{[{}<>][<>]}([(){}]{<><>})}><(<[()[]][{}{}]><{[]{}}({})>)(<({}[])<()()>>{<{}{}>{[ +([(({{<[<(([({{}<>}[[][]])<({}[]){{}()}>]{[[{}[]]][((){})]})<[{{{}<>}([]{})}{{[]<>}}]>)[{{<([]())({})> +<{{{<<(<{<(<{{<>()}}{({}<>)}>)>}((<{[<{}{}>([]<>)]<<[]()>[{}()]>}<{[<><>]<[]{}>}{{(){}}[[]()]}>>[({(()<>)<{} +((<[{<<{{{([[[[][]](<>[])]]{<({}[])([][])]<{{}{}}{()[]}>})}[[{<{<>[]}{<>{}}>}]]}{<[[((()<>)<()[]>){<()>({}[] +({[[{<{{<<([(<[]<>>{<>{}})<{()[]}(<>())>])<[{[<><>]({}{})}][<({}())><{()<>}(<>())>]>>>{{(([ +<((<<(<(<<{{{[{}]<()<>>}{[[]<>]{<><>}}}<[[<>{}]{()()}][<()()>{[][]}]>}{[{[{}()][{}{}]}(<{}()>[{}<>])]}>> +(([<({<[[(<(<([]())({}<>)>([{}()]{<>[]}))<{{{}{}}([]{})}<({}{})<{}<>>>>>[{{<<>[]><<>{}>}({{}<>})}{({[]()}(()< +{[((<({[([(([{(){}}{{}()}][<[]()>{(){}}])[[[{}[]]{{}<>}]<{[]{}}>]){(<[<><>][[][]]>)[{{<>{}}((){})>[([]())[ +[[<[<{({[({{([()<>]<()()>)}[<<[]()>>]}((({()()})(<{}>[<>()]))[(({}{}){[]}>(([][])<()()>)]))[{<[<[ +[<<([((<<(([[({}{})((){})]<({}[])[{}{}]>]<{{<><>}<[]>}>)[<{{<>()}<()()>}{<<>{}>[[]()]}>[(([][]) +{(<(<[[((<([{<[][]><()>}[[<>{}]]]<<((){}){[]())>[<()<>>(<>[])]>)<{<[[]][<>{}]>({<><>}[<>()])}({{{ +(<{({({<[[((<<{}<>><<>()>>({{}}<<>[])))[<<{}[]><<><>>>{{[]{}}(())}])[<[([]())<<>{}>]>[[[<>< +<[{[[{[({{{([<()()><<>[]>])([([]{})(<>())]{([]<>){()[]}})}<{({{}<>}{[]})([()()])}<[[[]<>><<>{}>]<[()()]<(){} +<<[<[{{({(({(<[]()>({}{}))([{}[]][[]()])}{{(()[]){<><>}}([<><>]{{}})})[{[[{}{}]({}())]{<<>{} +{{{[[[[[<(<<{(()[]){()<>}}<<(){}>(()())>>({(()[])}<<[][]>[<>()]>)>)[{[<(<>())>{<(){}>[{}{}]}] +(([<[[{(([([<<<>{}>((){})>[({}{})<()<>>]]([((){})({}())]])[[{[()()][()[]]}([[][]](<>()))][<{()< +([<{{[[{<{[({<()[]>{[]<>}}([()<>]<[]()>))]}>{[<({({}{})})>{{<[<>{}][()<>]>({[]}{[]<>})}{<[[]{}](<>()) +[{<<<{{((<{<<{[]()}<<>{}>>{((){}}{()()}}>}{[((()<>){<>})]({{()()}{(){}}}(<<>()>))}><[<{<{}><( +(((<<<<{((((<{<>[]}{<>()}>)(((<>{})(<><>))))))}><<{<(<<<[]{}><[]>><{[]()}{[]())>>{{<{}<>>}{{ +{{[{<(({[[[<[[(){}]]><<[{}{}]({}())>{{[][]}[()()]}>]<{<[<>{}][<>{}]>[(()[])<()[]>]}[{<{}<>>({ +{[{{[<[(((([{{{}{}}}({<>{}}[[][]])]){[<([]<>)([][])><{()<>}([]())>](<({}<>)<()>>(<()[]>{{}()})) +{{[(<<[<{<{[[<<><>>[()()]]]<(([]<>))<[[]{}]<[]>>>}>}>{{[<<<[()()]({}())>{<{}()>(<>[])}>([[(){}]<{}[]>]({( +[[[<<(<[{<[[<{<>[]}{{}[]}>]{({<>{}}[<>]]<({}{})[<><>]>}]((([{}{}][{}<>]))[({<>()}(<>{}))]) +{{((<<[({<<<{[(){}]({}())}([<>{}]<(){}>)>([(()<>)<{}[]>]<<[]{}><<>{}>>)>[[<{<>}((){})>[{()[]}<{}<>>]]( +((<<<<(<[{((<[[]{}](<><>)>{(()<>){()[]}}))}{<({(()())[(){}]}[[[]<>]<{}<>>])<([()[]])[{{}{}}{<><>}]>]}][<[{{ +[[({<{{([([<{<<>()><()()>}>((<{}<>>{<>{}})[(()<>)[{}[]]])])[{{(([]())[<><>])({<>[]}(<>{}))}[[<[]><<>[]>]({[ +[[(<(<[[(<{(({<>()}(<>[])){<<>[]>{()}}){({<>()}((){}))<<{}[]>[<><>]>}}{({<<>[]>[{}<>]})[[{( +({[<({<{<(<({([]<>){{}[]}}<({}{})[{}{}]>){{([]<>){(){}}}(<[]<>>{<><>})}><[[(<>())]{([]<>)} +{{[[[<{<(<{[(({}[])({}{}))<<()<>>>][<[{}{}]{()[]}>(<[]<>>{<><>})]}<{[<<>()>]<([]())<<>()>>}>>) +(({{{<(([[<(<((){})><[[]{}][{}()]>)<{[{}{}]}<(<>[])>>>]])({{{<[<()<>>{()<>}]>([<<>{}>(()())]<<<>{}>{[]} +{{[[[[({<{[{<[()<>]<<><>>>({<>()}<<>{}>)}(({[]<>}([]))<<<><>>[[]<>]>)]<(<<()()>([]<>>>{({}{}){()()}})[[[<>< +[<<{[[([(<{[{{[]()}{[][]}}{{[]()}{(){}}}]{{[{}<>]([]<>)}(<{}()><<>()>)}}<[<{{}<>}<[]<>>><[[]{}]([]{})>][{({ +[[[<<(({(<<((<{}<>><(){}>)<([]<>)(()[])>)[((<>())<(){}>){{(){}}{<>[]}}]><<({(){}}{{}<>})>{[<[]{}><[]{}>](<() +({({{<[<<<[{{<{}[]>[(){}]}{(<>[]){{}}}}]{[[{[][]}{[]<>}]{(())([]{})}](<({}{})(()())><{<>()}>)}>>>]([({ +<[(((<{<{[<{{{[]<>}{<><>}}{([][])[<>()]}][[[()<>]<{}[]>](({}<>)<[]()>)]>][(<{{{}[]}((){})}{{<>{}}({}() +{<{[({<<(<[<([<>]<[]()>)<({}()){()[]}>>([{()[]}[{}{}]])]>(([{[[]<>][[]<>]}[[<>()]<<>()>]>(((()[]){<>{}}){ +<(({<{[(<([(<{[]{}}{[]()}>){{(<><>){[][]}}[{{}()}<[][]>]}])>(<{{{[()<>][()<>]}({{}[]}[[]{}])}}(<{{[]{} +{<[<[{{<<<([[[{}[]]{<>[]}](<<>[]>[()()])][(([]<>)]])>([[<{()}{<><>}>[(<>[])<{}()>]]]{<{<[]{}>[[] +([{[[<<<<{<[({[]{}}(<>()))[<{}<>>[[]{}]]](([{}<>]){{[]()}[<>[]]})>[{(([][])[{}[]]){(<><>)(<>[])}}(<{()<>} +<<(([<{[((<[(<(){}>[<><>])[<<>[]><()())]]{<{()[]}(()<>)>}>)[<<{<(){}><{}()>}{[{}<>]<(){}>}>><[<{<>[]}{[][ +(<<[<{<(<<({<([]{}){[][]}>{<[][]>{<>{}}}}[(([]())<<><>>){<{}><<>[]>}])(<{[<>[]]}>{<[{}<>}{<>{}}><{<><>}{()[ +[[[[{<[{[<(<[(()())<{}[]>][(()())<()>]><{{()()}[<>{}]}[({}()><[]<>>]>)<{{[[]<>]<[][]>}{[<><>] +{{<(({{<{(<([<[][]>(()[])])<<{<><>}<[]<>>><(<>{})>>><{[[[]{}]{<>[]}](<<>{}>(<>[]))}[[<()<>><()<>>]<{()< +<[({<[[[(<{[(<{}()><(){}>)(<[][]><<>{}>)]<<{{}[]}<{}()>>[(<>())<<><>>]>>{<[([]{})[(){}]]{[( +[{<<<({<[[[<{{<>{}}<()<>>}{[[]()][(){}]}>{(({}[])<[]{}>){<()>(()[])}}]<{<({}<>)<{}[]>>[<{}{}><<><> +{<<[(<<<(<[<<{<><>}>({<>()}(()[]))>[([<><>][[]{}])(([]<>))]]>)>[({[<([[][]]({}))<((){}){[]<>}]>[[ +([<{<(<<{({<{<(){}>({}<>)}}{<[{}()][()<>]>{<[]<>>{<>[]}}}}<({[{}{}](<>[])}(<[][]>[{}<>]))< +{([<<<<{[<<[[<{}{}><[][]>]<{{}()}[()[]]>]<[(()[]){<>[]}][[[]()][()<>>]>>(<[{<>()}(<><>)]{<<>{}>{ +[[([(([[[<[((<()()>)([[]{}]<[]()>))]><{{[[[]{}]([]{})][(()<>)<{}<>>]}([{()<>}]{[<>()][{}[]]})} +<<{<[<<<({{(<<[]>([])>{<{}<>><<><>>}){<<()<>><()<>>><(<>[])<{}<>>}}}{([{[]<>}{<>{}}](<()()>[{}{}]))<{<[]> +[{{(([{[<{<{{<<><>><{}[]>}}{<(<>{}){[]}>[([]{})[[]{}]]}>(({[{}]<()[]>}))}><<[{(<{}[]><[][]>) +[[[<[<[{{[<[{([]())[()[]]}{<{}<>>[()[]]}]<<{[][]}<()[]>>(<{}<>>{[]{}})>>{<<<{}()>><([]<>)[<>()]>>{{( +{{{([{({[((((([][])[[]()])[(<><>)[()[]]])[[[<>[]]{{}<>}]<[{}[]]([][])>]){[[[[][]]<()<>>](<{}<>><{}{}> +<<<[({{(<((<<{{}()]<()>>(<(){}><<>{}>)>(<{<>()}<[][]>><{<><>}{[]()}>))[(<([][])[<><>]>(<()()>{{} +<[(([[(([[({[[[]()]{()()}](<<>{}>)}){<{{<>[]}{{}{}}}{<[]()>[{}{}]}][(<()[]>[<>[]])((<>{}))]}]{[<<<<> +({{[{<[{([[({[(){}]}[{[]{}}<(){}>])<<({})[[]()]>>]<(({(){}}<[]>)<[<>{}}(<>())>)>])}<<<<[[[[]<>][{}()]] +{{{[[([<{({{{<(){}><{}()>}([()()]<<>[]>)}<<[<>()]{{}<>}><<<><>>>>})([(<(()[])({}<>)>([{}<>](<>[]))){(<<>> +<([([[<{{({{[[<>[]]({}[])]}(<({}())><[<>{}]>)}{[(<{}[]>(<>[]))([[]{}]{[]})]({([][])(<>())})} +[({({{[{<{{(([{}]){<{}[]>([][])})({[[][]]<<>[]>}[<()<>><[]>])}<<<<{}{}>{[]()}>({[][]}[()()])>({([][])[<>{}]}[ +({<{(<([<[{<{<<>[]>({}{}>}([()<>]<[]<>>)>({{(){}}<<><>>}[({}{})])}]><<[(<<<>{}>([]())>)[[<[]<>>( +<[{<{<<<({[([({}<>){()()}][<()()>(<><>)]){<{()[]}<<>[]>>{{{}()}[<>[]]}}](((<[]()>{<>()})(({}<>)([]{})))({( +<<{<[[[<[<[[({()()}({}[]))[<()()>[()<>]]]]>][{[<<({}<>)[[][]]>{{{}[]}<()[]>)>]<{{[()[]][[]()]}}{<[ +<{<{({({[{<{[{()<>}]<<<><>><[]<>>>}[{<[]><(){}>}<{[]{}}(()<>)>]><{<{{}()}{(){}}>{<()<>>{[]()}}}((([]<>)<<> +{(({[([(((<<([()()]<<>[]>)[<<>()>(<>{})]>[<<<><>><()>>]>[((<()()>((){})))[[<()<>><()()>)({{}[]} +<[<[<{<[{[[([[()()]<{}<>>]){[[{}[]][<>()]]{[[]{}][()<>]}}]]<[{((<>())[[][]]>}([[()<>]<[][]>])](({[ +((<<[[{<({[([{<><>}[<>{}]]){(([]{}){(){}})}](<({{}()}<()<>>)({[]()}[[][]))>{{{{}()}[[][]]}<(<>{}){<>[]}>} +<{{{[([({{[(<<[]<>>[{}<>]><<[]{}>(())>)<[[<>{}]<{}<>>]<{()}<{}{}>>>]}{{[<(<>{})<[]()>><[(){}]>][{([]())}[< +[{<[<(<<{({[[<[]<>><()()>]([()()]<<>{}>)]}{(<{[]()}([]<>)><{()[]}>){<<[]()><{}<>>>({()}<<>[]>)}})}{ +[{(({[{[{(<[(<[]{}>(<><>))]<[{()}({}())]>><<[({}[]){<><>}](<[][]>[()[]])>[[([][])([]<>)](([]{}])]>)}]<[<[ +<({[([(<(((({(<>())<{}[]>}[(<>[]){()[]}]))){[([([]{})(<>()]]([()()][{}<>]))<<{{}}(<>[])>{{() +((({{({<{<({[(<>[]){()()}]([{}[]][{}{}])})(<<{[]{}}>{<[]<>>{()[]}}>)><{{{{{}()}}{[{}[]]<<>[]>} +(<[<<[([[{<[<({}()){()}>(<(){}><<><>>)]>{{([()[]]<<>()>)(<[]<>>)}{[{<>[]}[<>()]](<<>()><()[] +((<<({<((<(<({<><>}({}<>))({{}{}}(<>()))>((([]()){(){}})[(()())(()())]>)>){{<([{<>()}(<><>)]<{<>() +(({(<[({({([<{[]()}<<>()>>{(()<>)[[]()]}]{{[()()]((){})}{[{}<>]{(){}}}})}<<<(<()()>[{}{}])<([]{}){{}[] +{({[[{([[[<((<(){}>{{}()})[(<>{})])([[<>[]]<()[]>][(()())<[]{}>]>>]((({[{}<>]<{}{}>})({<{}[]>}{(<> +[[(({<<{[(<<(([][]){{}<>}){[{}[]]({}[])}>(({<><>})<(()<>)[<>()]})>{({[[]{}]((){})}[([]())])})(({([[][]] +<[<{[<<<{[{(<[<>[]]>{{(){}}[[]()]})}[<{[{}{}]}><(<{}()]{{}{}}){({}[])}>]]}>[({{(<({}[])({}<>)>[{{}<>}])}{ diff --git a/input11.txt b/input11.txt new file mode 100644 index 0000000..497e9f0 --- /dev/null +++ b/input11.txt @@ -0,0 +1,10 @@ +8258741254 +3335286211 +8468661311 +6164578353 +2138414553 +1785385447 +3441133751 +3586862837 +7568272878 +6833643144 diff --git a/input12.txt b/input12.txt new file mode 100644 index 0000000..a409ba5 --- /dev/null +++ b/input12.txt @@ -0,0 +1,21 @@ +TR-start +xx-JT +xx-TR +hc-dd +ab-JT +hc-end +dd-JT +ab-dd +TR-ab +vh-xx +hc-JT +TR-vh +xx-start +hc-ME +vh-dd +JT-bm +end-ab +dd-xx +end-TR +hc-TR +start-vh diff --git a/testdata10.txt b/testdata10.txt new file mode 100644 index 0000000..b1518d9 --- /dev/null +++ b/testdata10.txt @@ -0,0 +1,10 @@ +[({(<(())[]>[[{[]{<()<>> +[(()[<>])]({[<{<<[]>>( +{([(<{}[<>[]}>{[]{[(<()> +(((({<>}<{<{<>}{[]{[]{} +[[<[([]))<([[{}[[()]]] +[{[{({}]{}}([{[{{{}}([] +{<[[]]>}<{[{[{[]{()[[[] +[<(<(<(<{}))><([]([]() +<{([([[(<>()){}]>(<<{{ +<{([{{}}[<[[[<>{}]]]>[]] diff --git a/testdata12.txt b/testdata12.txt new file mode 100644 index 0000000..6fd8c41 --- /dev/null +++ b/testdata12.txt @@ -0,0 +1,7 @@ +start-A +start-b +A-c +A-b +b-d +A-end +b-end