This commit is contained in:
OMGOMG 2021-12-12 20:45:27 +01:00
parent dfdf652c0c
commit 17d32009b8
3 changed files with 150 additions and 0 deletions

98
input10 Normal file
View File

@ -0,0 +1,98 @@
{{[<[{({<[{(<[<>{}]({}[])>)({<()<>>(<>[])}[[()<>]{<>[]}])}[{{({}<>)[(){}]}{{<>[]}(<><>)}}<{[<>{}]{[]<>}}>]]>[
{{<((<<<[{(([[<>[]]]<(()<>){[]{}}>])}]([{[<<[]()>[()[]]>{(()[]){<><>}}][{(<>())([]{})}{{<>{}}[{}[
{{[<{{<[[<[<<([]())>>[<<(){}>{<><>}><{<><>}<[]<>>>]]]{<([<<>[]>[[]<>]]{{()[]}})<{{[][]}(()<>)}((
{((<<[{{{{<{[(<>)]<[<>{}](<>{})>}>{(<[[]<>]([][])>[<<>()>([]<>)])<<[{}<>](<>[])><<[]<>>{{}<>}>>}}{(
{{{[{([[<<{{(<[]<>><[]>){[<>()][[]{}]}}{({[][]}(<>[]))}}{(((()())(<>{}))({<>()}(<><>)))([{()[]}[()[]]][{
{[<[{((((<([<<<>[]>>(<[]{}>]]([(<>())<()<>>]))>((<{<<><>><{}<>>}[{{}{}}{{}[]}]>(<{[]()}>[{<>()}(<
[(({({{<{[[([[()()]]{{()<>}[{}{}]}><(([]{}){[]{}}){(()<>)[()[]]}>]<<({[]()}{()()})({[]()}{<><
{<<<<({{([[{[[()<>]{[]()}]([(){}]({}()))}{{<{}<>>}{[{}()]<(){})}}]{[{[()()]<[][]>}]}]([({<{}>(<>())})
({(((([{{[[[{(<><>)({}<>)}]{{{[][]}{{}()}}{{<><>}(()<>)}}]][{[{{[]<>}([]()))]}[<({[]<>}<(){}>){<<><>>({}{}
<[[{[<{<{[{[({{}()}[{}<>])[([]())[<><>]]]<{{{}<>}[[]{}]}>}[{[{<>{}}([]{})]}])}>[{<[(({<>{}}([]()))(<{}<>><{}(
({[({{([(<[{(([]()))<{<>()}[()<>]>}](({{()()}[<>()]}<<<>[]>[<><>]>))>{(({<[][]>}<{[][]}[()[]]>)<[<
{{<(<[<{{<[{[(()[])([]())}<[<>()]<<>>>}{[[()[]]{()[]}][{{}}{{}()}]}]{<<({}<>)[{}{}]>(<{}[]>{()[]})>{(
<{<<<({[({[{{<<>()>{[]{}}}}{<<()<>>[[][]]>[<{}<>>[{}{}]]}}}{({{{()[]}[{}]}<((){}){()<>}>}<<[()<>]>[{[][]
<<[[<{<{(<[[(({}[])[()[]]){<[]()>}]<(<<>[]>(<>[]))[[[]()]<[]()>]}]{[[{<>[]}[{}]][<[]{}>({}<>
((({[{{{<[([({<>[]}[()()]}[[{}[]]([]<>)]]<(((){})(<><>))([()[]](<>()))>)]<(<([[]()]({}<>))[({}[])]>)<[<<()[
<<[{({[[([{{<<<>{}><[]()>><([][])[()[]]>}<([()[]]([]{})){(()){[][]}}}}]<{<<[<><>]<(){}>>(([]<>)<{}{}>)><
(<[([<<((<<[({[]{}}([]{}))({[]()}<()>)]{{<()<>><(){}>}{([]{})}}>[(((()()){()}){({}<>)[()()]}){{(())<<>[]>}}
[<{{[(<[(<[[({<>{}}<<>[]>){[<><>]{<><>}}]<<[<><>]({}())>[{{}[]}[[]{}]]>]{{{{<>()}}{<{}[]){[]{}}}}<
(<(<(({(<<(<[{{}{}}[[]<>]]>{[<()[]>(()<>)]({[]<>}}})>>)})[[<[[{[[<[][]>{()[]}]]}[[{<{}>{[][]}}]<{
(<{{{<[<<{{[[[{}<>]<[]>]](<[[]{}]((){})>((()[])))}<([{()<>}{<>{}})[[[]{}]{<>()}])>}>{<<[({{}{}}([]()))<([]
(<(({[{<{<<<(([][])(()()))(<{}()>)><({[]<>}[()[]])<<(){}>[{}{}]>>>[<[[[]<>]<<>()>][[(){}](<><>)]
[[[[[<{{{<<<{{<>()}(()[])}<{<>{}}<<>[]>>>([[{}<>][[]()]]({()()}(<>[])))>>}}[(([[((()()))[([]())[{}{}]]]{(<{
{{({([<([{[<{[<>[]]<<><>>}[(<><>)([][])]>({[()<>]<[]()>}{<{}()>})]<([<{}{}>([]())))>}{[<(([]<>)(
<<{<((<(<{{[([<>[]][{}<>]){({}())[()()]}]([({}())<()[]>]({{}}>)}[<<(<>{})>(<()[]>([][]))>(([<>[]]<()<>>)<[{
{[<[<<(<{{((<{{}()}<[][]>>[[(){}]{()()}])<{[<>[]][{}{}]}{[[]{}]}>){<<{()()}{<>()}>>({[<>[]]<(){}
{<[((<{<(<([(<()<>><[]{}>){{<>}[{}[]]}]{(<()()>((){}))({{}<>}[()[]])})[{({<>[]})<{<>{}}<[][]>
<(<{{<(([<<{<([]{})[<><>]>{<<><>><(){}>}}<<<[]{}>>{[<><>](<>{})}>>({<{()[]}({}())><[{}[]]<(){}>>})>[{<[{{
<<(([<[<({{{([[]<>]<{}{}>)}[{(<>[])<[][]>}{{{}{}}(<>())}]}})<({[[<<><>><<>()>][{<>[]}({}())]]<<[{}()
<<<{{[<({<<{{{[]{}}{{}[]}}{{()[]}<{}{}>}}>{({{()<>}[<>[]]}({[]<>}(()()))){<<[]<>>{[][]}><<
[([[{[(<[{<<[((){})<()>]><{(()())([]())}{<()<>]<[][]>}>>[{{((){}){<>[]}}<[()()](<><>)>}[[([
(<{(<{<<{{<<[<[]<>><[][]>]{{{}{}}}>([[()[]]{[]<>}]<[()[]]<<><>>>)>[({[[]{}]({}[])}{{(){}}{<><
[{<<<<({{[({({[]{}}[<>{}])[<<>{}>({}<>)]}{{({})}({[]{}}({}{}))}){<<{{}[]}<{}<>>>[{<>[]}<[][]>]
{{<<({<{<[[([[()<>][[]{}>]((()[])))]([{((){}){()[]}}<<<>{}>{{}<>}>])]>}>}){([[[[(<([<>()])<<()()><[]()>>>
[<<[(<<<<<{([{<>}]<({}{})<[]<>>>)<[[(){}]<<><>>]{{{}[]}{{}[]}}>}<{<{[]<>}([][])><[{}()]{{}[]}>}(<{<><>}{<>()
(([(([<{(<{{<[()[]][{}[]]><<()>([]())>}[(<()<>>({}()))<{[]()}{[]()}>]}[({{[]{}}}<{<><>}(()[])>)<[{<>[]}{<>[]
([<{<{<[{({<{[[]()](<><>)}(<<>{}>{{}{}})><<<[]<>>{{}()}>{<(){}>[[]()]}>}[{[{{}}([]{})]]])(({{{
[<{[{[{<[{{[(([]<>)<()<>>)(<()()><()()>)][<([]<>)<<>{}>>[(<>{}){(){}}]]}{(<{()<>}{[]{}}>(((){
<(<{[[{<{<{(<(<>[])[{}<>]>(<{}<>>[{}[]]))[{{<>[]}([]{})}[(<>()){<>()}]]}<[((<>){()[]})[({}<>)(()[]
{{(<[{<{<(<[<(<>[])([][])>[([][])]][<({}<>)<<><>>><[()<>]{<>{}}>]>)[(([[[]]]<<()[]>>)<[<()[]>[()[]]]([()()]
{<({{<[([([{[[<><>]{{}{}}]}<{[{}<>]({}{})}<<()>[<>[]]>>])<(<{([]{}){[]()}}[<{}()>{{}}]>(<(<
{<[{{{{{<[{(<({}{})[()]>[([]{}){<>()}])[{[<>[]](<>{})}<<<>[]>[()<>]>]}]>([({(<()[]>[{}[]]){{[][
{<{{<{[[{[<<{(<>()){(){}}}>{({[][]}[[]()])([{}{}](()))}><{{<<>[]>{{}{}>}<([]<>)<<>()>>}({[[]{}][[]<>]}
<(<[(((([{<<{{()[]}[()[]]}({[]<>}<(){}>)>({{[]{}}<<>>}{[<>[]]<()<>>})><<[<[]<>>{<><>}]({[]{}
<([[[[<(((({[({}()){<>{}}][{<>}<()[]>]}(([()[]]<{}<>>)[<<>()>(<>[])]))<[<[[]()]{[]<>}>([<>{}]<[]{}>)](<(()[
([<{[{([[{[{(<(){}>(<>())){([]())[()()]}}([(<>{})<[]<>>]{<{}()>[[]()]})]<(([<>{}](<>[]))[<{}
[[<<{[{[<[{(<{{}<>}<()<>>>([[]{}]{<><>}))<<[{}()]{<>[]}>[{{}[]}{{}<>}]>}]>[{{{<<()<>>{{}[]}
((<[{<({([{{(([]{})(<>()))}[[<[]<>>][[[]<>][()()]]]}[{[({})({}[])]<[[]()][[]()}>}[{[()[]]<<>
{[(<((<{(<[[{([]()){{}()}}][{<[][]>[<>()]}{[[]][[]{}]}]][{{<()()>{<><>}}<{{}[]}{<>()}>}]>(
{{[<(({<[{{[{(<>{})([]<>)}{{()<>}[[][]]}](((<>{})[{}[]])([{}<>]{{}[]}))}[<<[()()][<><>]><[
{(({[[([[({{[({}{})[{}{}]][<()()>({}{})]}{(<<>{}>{()[]}){[()]({}[])}>}){((<<{}{}>{{}{}}>[<()<
[<{(<[([(((<{<<>[]>[<>()]}({[]()}({}()))>(({<>{}}{[]})<{()<>}(<><>)>)))([<<<{}()>{<>{}}>[<[
[{{[(<{[<([[<{<>{}}<(){}>>]{{(())}((<>[]))}]({({{}<>}[(){}])>))({<{(<><>)[<>{}]}<<[][]><<>{}>>>}((
([[(({({(<([({{}}[<>()])<({}{})>]((([]()>[[][]])))>)})(<<<[<{[<>](()())}[(()[])(()())]>]{([[[][]]{[]{}}
{([({{<([[<<[[{}<>]<()()>]><{{[]}(<><>)}>><<{<{}()>[<><>]}>[[{()}{{}{}}]]>]])[({([<<()<>>([]<
<{{{(({{[(((<([][])[{}[]]>((<>())[{}{}]))[<[[]()](<>{})>[(()()){{}[]}]]))][<[[[<<>[])(<>[])][
<<<[[[<[[[<[[({}[])<[]<>>]([{}<>][{}[]])]><(({{}()}))({[()]<[]<>>}<[<>{}]({}{})>)]]<[[<{[]
({{[<[(<{<{{([<>[]])(([][]){<><>})}}{(({[]{}})<{{}}[<>{}]>){[<[]<>>{()<>}]}}>}{<(<<[<>[]](<><>)>[<()>{()
<<[(<[{[[(({{(<>{})<{}{}>}}))<<(((()[]){(){}})([[]<>]<<>{}>})<[<{}{}>]([()]<<>[]>)>>>]]<{(((
({({(<<{<(<([{<>[]}<<><>>])>[(<[<>()](<>())>[<[]{}><()()>]){([[]{}])[[{}{}]{[]}]}])<[((<(){}>){([]
{{[<<[{[<[(((({}<>){{}{}})<<<>[]>[{}[]]>)[{<{}[]>{<>()}}[<{}[]>[<>[]]]])<(<[[]()>><(<>{})<()<
<(<(<<[<({[[(({}{})[[][]])<[{}{}][<>[]]>]]{<[{<>[]}<[]<>>]{{<>{}}{[]{}}}>{<[<><>](<>())>[[<>
{(((({{<<<[[{[[][]>{<>{}}}{[{}{}]{()<>}}]{{[[]]}[[[][]][()()]]}]({{[[]<>][[]<>]}<{{}{}}({}
({([{<{(<{({[([]())[()[]]]{([]<>){<>[])}}[([[]{}](()<>))<<()<>><{}[]>>])<((<()[]>{<>[]}){{{}()
[{<{[{[<[{(<<({}{})<()[])>(<()<>>(()))>{((<>())[{}()])<{<><>}<[]<>>>}){{(<{}{}>{<>[]})[{{}}[[]{}]]}<[
{[{<[[[[[(<{{[()[]]{{}<>}}{([][])[(){}]}}>{{<{<>()>([]<>)>[({}{})]}{{<[]>}[[[]<>]([]<>)]}})<
{[<{{({((<<(<({}<>)<<>[]>>({{}}[()()]))[[{<><>}[[]{}]]]>>){{<{{([]{})[<><>]}}>(([<{}{}><(){}>]{({}<>)
{{{<[((({(<{{({}<>)[<>[]]}[([]<>){()[]}]}{(<[]<>>[[]{}])}>){<<{{[]()}[<>[]]}>[<<[]{}>[(){}]>]>
[{{[<{[{({{<<(())<()<>}>(<{}{}><<>[]>)>[[<{}>([]{})]<<<>[]><{}[]>>]}((<{{}<>}{()()}>([()()]{{}<>})))
({<[<[<[<<{<[<{}[]>]>{<{{}<>}{()<>}>([()<>][<><>])}}{{[<<>()>]{{[][]}{<>()}}}{<(<>[])<<><>>><(<>{})<<><
{{{([[<[[(((<(<>[])<<>[]>>{<{}<>>{()}}><[{(){}}({}<>)][[<>[]][{}{}]]>)([({[][]}[[]<>]){<(){}>}]
{(<{{{<[<[[[(<<>[]>([][]))]]]>]>}}([((<<[{(<{}>(<>{})){[()()]{[][]}}}{{([]<>><{}<>>}<{{}()}(
([(<[[((([[((((){})({}()))({[]()}{<>()}))[([<><>])[[<>[]]<{}[]>]]]]<<({<(){}>{{}<>}}({(){}}[{}<>]))([(
{[[[[{{[[{{<(([][]))(([]<>){[]{}})><{<{}{}>{[]<>}}<{{}<>}(()())>>}([{<[][]>{[][]}}<[<>]{<>[]}>]<{<()()>[()
<({{[((<<<([<({}())[()<>]>(<()<>>[<><>])][{(<><>)[<>{}]}([<>{}](<>()))])(<[{(){}}[[]{}]>>)
<((({([{<<<[((()[])[<>[]]){[<>{}](()<>)}]{[<{}[]>]<([]<>){<>{}}>}>[<<[{}[]]<(){}>>>]>{<(((<>[]){<>()}){{<
[<(<<({<<[<{{<[]()>{{}()}}[{{}{}}{[][]}]}>[{(({}[])({}{}))<((){}){{}[]}>}{(([]{})([]{}))}]][({<<()>(<>())>{{<
({<({(([<{[(({(){}}{<><>}){({}[])<()()>})]<<{[[]()]<[][]>}>[{<<>[]>[[]{}]}[([]<>]]]>}[<{({{}()})((()<>)({}())
{({[[{({{<<(<[[]{}]{<>[]}>([[]<>]))((<{}()>{()()})<<{}()><(){}>>}>{{[{[]{}}<[]()>](({}[])[<>{}])}<{[<>[]]
[([<({{<<([<[[{}{}]((){})]<(<>[])>>][{[[<>[]]{<>()}]{<<>{}>({}())}}({[<>()]{<>[])}{<<>()>({}())})]
[[([[(<<({([{<[]()>({})}[<()()>{()[]}]][<[{}<>>{[]{}}>])<[(<[]()>)({<>[]}<[]{}>)]>})>{[<<{{{{}[]}[{}<
[<[{<([(<[([[([]<>){()()}][[[]<>]{{}<>}]]{[[<><>]][<<>{}><{}{}>]}){{(([])[()<>])(<<>{}><{}[]>)}}]({<((<>
{(<(<{<<({{[[<()()><{}[]>]{<()<>>[{}{}]}][(<()()>({}{}))({<><>}<{}[]>)]}{<<([]{}){[]()}>[((){})[()
{({[[<[<<{[(<([][])><[<><>][{}<>]>)<<{<>()}(<>[])>{({}{})[()]}>]{[{<()[]>[(){}]}[<[]()>[(){}]]]{<
{(<[[[<(<{{{[{()()}[<>]](({}[])[[][]])}({([][])[(){}]}{{[]{}}{()<>}}}}}<{[(({}<>)<()()>){<(){}>[{}<>]}](<<<
{{{{{[[[<[(<<([][])<<>()>>[{{}{}}{[]<>}]><{<{}{}>({}())}>)(({{<>{}}}))][({<<[]{}>>{<()()>}
(([[({{[<<[{{({}<>)(<><>)>}([<[]<>>{{}()}]({[]()}[(){}]))]><[(((()<>)<<>[]>))[(<()[]>[()<>]){[()()][{}()]}]
[({[[<{<{((<<([][])<()()>>{([]{})([]{})}>(<[[]<>](())><{{}[]>({}[])>))({<[{}]<()[]>><({}<>)([]<>)>}<[<()()>
{([<<({<{[{[{([]<>){()()}}][[(<>[])<()()>]({(){}})]}[{[{[][]}<{}[]>]{<()()>>}{<{[]()}<<>()>>[({}<>)[(
[[((<{(([<((<(<>)[()]>(<{}{}>)){<{<><>}<()[]>>([<>()]({}[]))})<{<(()()){()[]}>}[({{}{}}([]()))<{
<{[(<{({<(<[{[{}[]]}(({}()){{}<>})]{((()[])[[]<>])<[()<>]>}>((<{<><>}([]<>)>))){[[({(){}}<<><>>)<{{
({([{[<{(<({<[()<>]<{}()>>[[{}{}][()()]]}[(<[]<>><{}{}>)<{{}<>}[<>()]>])>{([{<[]{}><{}<>>}<({}{}){
<([[<<[<{({<([()<>](()<>))[{<>())<{}{}>]><[{[]<>}](([]<>)([]<>))>})[<[{((){})[()<>]}{[{}<>]<<><>>}]>]}><
<{<[((<{[{([{(()<>)([][])}][(({}[])(()[])){{()[]}<<><>>}])<{[{[]()}<[]{}>]}<{({}{})<<><>>}<{()()}(<>{})>>>}
{{<[<({(<[[<{(())}([<><>]([]<>))>(({<>()}<()()>){{<>()}{[]{}}})]<{([[]<>]{[]()})<<[]()>{()<>)>}<{{[
[<([{{[[<(({{(<>())<<>()>}<[[]<>][[]{}]>}<(<{}()>(<>[]))[{[]()}[{}<>]}>)[[{[[]<>](<>{})}[[[]{}][[]{}]
{[{([<({<{[{<(<><>)([][])>([[]<>](()()))}<{<[]<>>}[[{}()]{<>[]}]>](<<[<>()]<<>()>>([[]<>])>{{[{}{}][<>[]]}{
{{<<<<((({(([{{}()}(<>{})]{{<>()}[()]})<[(()()){<>[]}]{<<>{}>}>)([({[]{}}<{}<>>)]<[([][]){(){})]([[]
({[(((<[([[[(({}<>)<()<>>)<{<>()}>]]{{(<{}[]>[<>[]])<({}<>)>}[{<<>>}{[[]{}][{}()]}]}])<<(<{{<>{}}[{}[]

42
ten.py Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env python3
from useful import *
def parseline(s):
return s
return [int(c) for c in s]
return [int(x) for x in s.strip().split(',')]
with open(0) as f:
L = [parseline(l) for l in lines(f)]
total = 0
d = {
')': 3,
']': 57,
'}': 1197,
'>': 25137,
}
inc = {
'(': 1,
'[': 2,
'{': 3,
'<': 4,
}
fixscores = []
for l in L:
fixtotal = 0
for i in range(len(l)):
for p in '{} <> [] ()'.split():
l = l.replace(p, '')
lincomplete = l # save this
for p in '{ < [ ('.split():
l = l.replace(p, '')
if not l: # possibly incomplete
fixscores.append(reduce(lambda acc, c: acc * 5 + inc[c], lincomplete[::-1], 0))
continue
total += d[l[0]]
print( total)
print(sorted(fixscores)[len(fixscores)//2])

10
test10 Normal file
View File

@ -0,0 +1,10 @@
[({(<(())[]>[[{[]{<()<>>
[(()[<>])]({[<{<<[]>>(
{([(<{}[<>[]}>{[]{[(<()>
(((({<>}<{<{<>}{[]{[]{}
[[<[([]))<([[{}[[()]]]
[{[{({}]{}}([{[{{{}}([]
{<[[]]>}<{[{[{[]{()[[[]
[<(<(<(<{}))><([]([]()
<{([([[(<>()){}]>(<<{{
<{([{{}}[<[[[<>{}]]]>[]]