diff --git a/advent_of_code/d1/1.txt b/advent_of_code/2021/d1/1.txt similarity index 100% rename from advent_of_code/d1/1.txt rename to advent_of_code/2021/d1/1.txt diff --git a/advent_of_code/d1/Cargo.lock b/advent_of_code/2021/d1/Cargo.lock similarity index 100% rename from advent_of_code/d1/Cargo.lock rename to advent_of_code/2021/d1/Cargo.lock diff --git a/advent_of_code/d1/Cargo.toml b/advent_of_code/2021/d1/Cargo.toml similarity index 100% rename from advent_of_code/d1/Cargo.toml rename to advent_of_code/2021/d1/Cargo.toml diff --git a/advent_of_code/d1/src/main.rs b/advent_of_code/2021/d1/src/main.rs similarity index 100% rename from advent_of_code/d1/src/main.rs rename to advent_of_code/2021/d1/src/main.rs diff --git a/advent_of_code/2021/d10/input.txt b/advent_of_code/2021/d10/input.txt new file mode 100644 index 0000000..cfcaf03 --- /dev/null +++ b/advent_of_code/2021/d10/input.txt @@ -0,0 +1,102 @@ +{<{<{[<[{{([{{{}()}<{}()>}<[{}]>]<<{{}<>}([]<>)>[({}<>){()[]}]>)[[([(){}][<><>])<<()>{()()}>]]}}[(<{[(<> +[<{{[[(({({<{{<>[]}[[][]]}[{{}()}[[][]]]>}{<[{()<>]<[]()>]{([][]){{}[]}}>})(([<[[]()][()()]><{[]}(<>< +{{<{[{[{<{[[[[[]()]]<<{}{}}[{}()]>]]}[<<<<[]()><[][]>><<()<>>({}<>)>>{{{{}{}}[{}<>]}[[<><>]<[ +([{((<{((<[(({{}[]}<()()>)[{{}<>}[()()]})<{{()()}[<><>]}>]>))}({<<[({{[]<>}[<>()]}<((){}){[][]}>)[{[{}[ +{([<[((<[[<<({[]()}[[]{}]){<{}<>>{()[]}}>[{<{}{}>[(){}]}<({}<>)[[]()]>]>](({{<[]()>(()[])}{<<>()>({ +[({[([{<<{<<(<()()>)<[()<>]([]{})>>{<({}[]>{[][]}>([()[]]{(){}})}>{{[{()()}{{}<>}]({<>{}}<{}{}>)}[ +<[({(<([{<<<(([]()){()()})[<{}><<>>]><({{}<>](<><>))([{}[]]{(){}})>>(((<[]<>>({}[]))([<>()](<> +<{[[{<<[{(([<([][])<{}<>>>{{<>[]}{()}}]{(<()<>>(()<>)){<{}[]>[[]()]}})<(<({}()){[]{}}>(<[]()>[[]{}])){<(<> +[<[[({<<[[<{{(<>())}<<{}[]>{{}<>}>}[(((){})<()[])){<{}()>[<>()]}]>{[([{}[]](<>{}))<{<>()}{[]()}>](({(){}}<{ +(<([<[<{{<[{[(<>())<()()>](<<>[]>{()()})}<<{[]{}}>[(<><>){<>[]}]>]<(<<[]<>><<>{}>>(([])[<>{}]))>>>({<< +(([{(({<{<{(({{}[]}{<>[]}){<()()><<>{}>})[[({}[]){(){}>]]}[[{{<>[]}{()<>}}[{{}}{[][]}]]<<<()()>([][] +[<([{{<[[{<([<{}{}>{(){}}]{[[]{}]{<>[]}})([(<>{})[()[]]])><([{<><>}([]{})]({()()}(<>[])))[[[(){}]{<><>}]<<[ +<((<<<[<<([({{()[]}})[{{<>[]}([]{})}{{[]<>)({}<>)}]][[<{<>}(()())>[[<>()]<{}{}>]][<({}()){<>}>{{()()}{<><>} +[{{[{[({([[<({()}((){}))>{([[]<>]<[][]>)}]{({([]<>)<()()>}(<()<>><<>()>)){{<<>{}>{()[]}}[(()())<[ +(([[<[[{[{[([[{}()]<[]()>){<()<>>{{}<>}})<{[{}[]]{()<>}}{(()){<>[]}}>]({[{()[]}[<>]]}<(<{} +[{[[[<(<<([[<{()<>}<(){}>>({{}()}<<>{}>)](<{{}()}><<{}[]}<<>[]>>)]<<({[][]}[()[]])[<{}{}>(<>[])]>>){<{{{()()} +(<[<<{[{[[<{<<()()>{<>()}>}>]{[<([<>[]][()[]])<[<>[]]{{}()}>>((<()()>({}<>))<{(){}}{<>{}}>)][<{(<>{}>}{ +((<[{<<<<([{{(<>())<(){}>}(<{}<>>[<>{}])}({[<>()]{[]<>}})])[{((<{}<>><()<>>)(<[][]>[()]))<({<>[]} +([((((([[{(<<<<>()>(<>[])>>[[(<>[])<<>{}>}<[[]{}](()[])>])([[({}<>)<[]()>]<[{}{}]{<>[]}>](<(<>())>{< +<<({[{[{((<<({()<>}<[]{}>)({<>[]})><{([]{})}((()[]))>>(({([]<>){{}{}}})<[{{}[]}[(){}]](<()[]><<>{}>)>) +{<[(({<[[([((<()<>><<><>>)(({}())<{}()>))<<<()()>{[]}>[{[][]}[{}[]]]>]{({{<>{}}<(){}>}[<()[]>{<>[]}>)(<[<> +{{({<[((([([<<[]{}>[()()]>(<[]{}>)]{[{[]()}]<<(){}>[()<>]>})[{{[{}<>]}[[<>{}]{<><>}]}]]((<{{{}[]}}>[[<[]<> +<[(<(<[((<{{[<(){}>[[][]]]}}>))]>)([({<(<<{([][])[()[]]}(<{}[]><()<>>)>{[<(){}>([][])]}>{[<<{ +(<{{<{<<[((<(<{}{}><[]<>>)<<{}{}><(){}>>>([{<><>}[()()]][{<>[]}([]<>)])))<<{{<<><>>}(<[]{}>( +[(((({{[[{{([(<>{})<[][]>])([[()()][{}]](<{}<>>{<><>}))}}<[<{[()]<[]()>}{(<>[]){<>()}}>[[(<>[])[(){}]](({}()) +({{{<{[<{[{<{{{}{}}}[[(){}]{()[]}]>[[<[]<>>{<><>}]([(){}])]}[({{()[]}[{}[]]})[[{<>[]}<{}[]>]]]]}>](({{[[ +<{<[{{[{<[[({<[]<>>}{{()()}(<>[])})]]>}[{([[[<<>[]><[]{}>][{<><>}]][((()())(()()))([{}()])] +<<<[([({{<<{[({}<>)[()[]]]({()[]}({}[]))}{[{<>[]][[]]]}>>}}[[({[({()[]}<()>)]<[[()<>]{()<>}][ +{[<({{{{<{{{[<()<>>[{}<>]]<[()()]<[][]>>}({<[][]>[()()]}<<[][]><[]()>>)}{([(()<>)<()()>])}>(([<[< +[{<{[<<{{[{[([()<>](()[]))]((<{}{}>)(<[]<>>[<><>]))}]}}>><<<({{{[((){})(<><>)]((()<>){[][]})}(< +[({(<{<{[<{([{[]()}[()()]])><[<{[]<>}{{}()}><(()())(()<>)>](<[[]{}]>[([]{})<()()>])>>][{([<([]())[[]<>]> +{{(<(<{{({((({{}[]}<<>{}>){<{}()>[[][]]})<{{[]()}{()()}}(<{}[]>{()()})>)})}[<<[[{{<>[]}{<>{}}}{{[ +<<[<{{[<<{({{(<><>)({}())}({{}<>}[<>])}{[(()<>)<(){}>]{<<><>><[][]>}})<({<[]{}>[[][]]}<<<>{}>{()}>)>}>[< +<{(<[<(((<({[[{}[]>(<>[])]<{[]<>}>}({(()())<{}{}>}<<<>[]>[<>()]>)){<<<[]{}>{()[]}>([[]{}]([]{}))><<{<>[]} +<{{{[(({<{<[<<[]()>({}())>](<((){})[(){}]>(<<>>([]()))))}>([[<[<{}[]><[]()>]{({}[])({}())}>[[({ +{([{(<{([<{([{[]()}(<>[])]<<{}<>>(<>{})})[{<<>[]>}(<<><>>[<><>])]}[[{([][])({}())}](<(<>{})(<>)>(([]()){{} +([<<{[[<((([<{()[]}>]<{[[][]]({}<>)}])<([{()[]}<()()>]{<<><>>[()()]})>))<[<<<([]<>)[()[]]> +[[{([{([{[<(<({})[()[]]>[{[]()}[()()]]}[<{{}()}({}[])>(<[]<>>[()[]])]>([((()[])[(){}])]<[{ +{{[([[(<(([[[{[]{}}[()()]][[[]{}][<>[]]]][{<<>[]>}]][(<<(){}>{{}<>}>)[<[[]{}]{()()}>[((){}) +[({[[([[(<[{<([]{})(<><>)>}][<[[()()]<(){}>][[(){}][{}]]>([({}<>)[[]<>]]{[()[]]<[]()>})]>[[<(([]())< +[<(<[<<{[<{<<[{}()]<<><>>>{[()<>]<[]<>>}><[([]<>)[{}])<{[]()}[<><>]>>}[[<<<>{}><()[]>>(({}[] +(({[{{{[<[{[[<()[]>({}{})][(()[])[(){}]]]({{[]()}}[(<>())<<>[]>])}]<([<<<>[]>[()[]]>{[()<>]<<><>>}]([(< +({<(({([[<(<({<>()}[()<>])({<><>}<[][]>)>([[<>()]([]())]))>]{{[{{{{}[]}}<[<><>]<<>[]>>}}}[{ +[(<([({<<(<{<{{}()}{[]()}>(<()()>{{}{}})}{{([]{})<[]>}<(<><>)>}>[<{<[]>([]<>)}({<><>}{[]{}} +<{<[[((([{<[({{}[]}[<>()])(<{}[]>(<>{}))][{{()[]}([][])}({[]})]>({<[()[]]<{}{}>>{<[]{}>{()[]}}}([[{}][{} +[([[<(<[((<[({{}{}}[{}[]]){[[]()](<>())}]>){[({[()()]([]<>)}<<<>{}>(<>()>>)]{{((<>())[{}()])[[()<>]<[] +{{[<{([<[(<([(<>())<<>{}>])[{[()[]][<>{}]}([[]()]<{}<>>)]>)]<[{[{(())(<>{})}[({}{}){[]()}]]}<<{([]{})}[< +([{{<<<([<((({{}{}}((){})){[<><>][[]<>]})<[{[][]}[()()]]([[]<>]{[]()})>)[[<([][]){<><>}>][< +((<(<[([<<<({[<>[]][{}<>]}<{[]()}{{}{}}>)[({{}{}}([]()))(<()><<>>)}>(([<(){}>((){})]){<<<>[]>[{}{}]>({(){}}< +(<<{{[[[<({({[{}{}]((){})}({<><>}({}<>)))}[(<[{}[]][()<>]>{({}{})(()())})<<[[]{}](<>)>([(){}][<><>])>])[ +<({{<<(({<[((<{}()>{<>{}}){{{}<>}{<>{}}}){({[]()}<{}[]>)<{()[]}[{}()]>}]{{[{()<>}(<><>)][<<> +<[{[[(<<{{(({{{}<>}{<>()}}(<[]{}>))]([[[<>{}](<>)]{(()())<(){}>}][(({}()){<>()})[(()())[{}{}]]])}<<{{<()() +[{{([<<{[{<([(())]<<{}>[[]<>]>){([()()]){(<>[]]([][])}}>{<[([]{})]{{{}}((){})}><{[<>[]][<>[]]}{{<><>}< +{{{{<((<<{({<(<>[])[<>{}]>{([]<>){[][]}}}[[{[]()}{{}[]}]{[[]{}]<<>()>}])}(<([<{}{})][[{}()]<()()>])(<([][])( +<{{[{[[[[{((((()())(()()))<<()>{()<>}>){[{[]{}]][(<><>)[{}{}]]}){{([<>[]]({}<>))((<>()){[]<>})}({<<>{}>< +({({[<<<[{[{([{}()}{<>[]})[(()[]){{}{}}]}]{<([()<>]((){})){(<>{})}>[<{<>()}([])><{[]{}}<[]()>>]}}]{([(<[() +<{({(<{<((<([[{}[]][<>()]])[{(<>)(()[])}([<>()]<[]()>)]>)<<{[<{}<>>[[]()]]}[<((){})<<>()>> +((({(((<<[{<<([]<>)[{}()]>((<><>)({}()))>([[<>[]](<>{})][<{}{}>{[][]}])}]>>)))}){[<{{{(<<[[<{}()> +[<{<<{[<<<[{[{{}[]}[{}[]]]((<>[]){(){}})}{<<{}<>>{<>()}>(([]{}))>][{[<<>[]>]({{}{}}<[]<>>)}]>> +({{[(<{[{[{{(<()[]>(()()))<<{}()><[]()>>}[(<[]>[{}()])[<{}{}>(()[])]]}]}({{<<{[]<>}((){})><<[] +{(<[(<<<[({([((){})]({()<>}{[]<>}))({{<>{}}([][])})}{(({<>{}}<{}<>>)(({}{}){()[]}))[{([]())( +<{([[[(<{[{{{[()<>]}{[<><>][[]<>]}}((([]){{}[]})<<{}>(()<>)>)}<((<(){}>{{}{}})){{(()[]}[()<>]}{[[]()][<>()] +<[{{<([{{({(<{<>[]}{<>{}}>)[{{[][]}<<>{}>}[[(){}]<()<>>]]}<(({[]{}}({}{})){{{}{}}<<>()>})( +{[{{{([({{<<([{}[]][[][])){<[][]>(<>())}><<(<>())<{}{}>>(<[][]>{<><>})>>(<([(){}]<<>{}>)[<[] +(<(<({[[[<<{<[{}<>]([]())>{([]())[()<>]}}<{{<><>}[{}<>]}{[<><>]<[][]>}>>[({[(){}][{}()]}<<[]>([]<>)>)]>[< +{{[({[<[<<<<<{[]{}}<<>[]>>({[]<>}{[]()})><<[[]<>]>[<()<>>{<><>}]]>[[{<()<>><[]<>>}<([]{})(<>{})>]({([ +{<[([([[<<<{{<()[]>[<>[]]}[[<>[]]([][])]}([[<><>]<()<>>])>({{[[]{}]{{}<>}}<[<><>][<>()]>}<[[{}[] +<<<<[[<[<[[{{[[]{}]{{}<>}}(<<>()>([]{}))}{[{()[]}{{}{}}][{<><>}(())]}]<((<{}[]>[<>{}])({[]{}}(<>{})))[< +<{[{({{{((<<[<<>[]>[{}()]]>{[([]())((){})]([[]()])}>[[({[]<>]{()()}){{()[]}{{}[]}}]<{{<>{}}([] +{{(<<{[[[[(<([{}[]]([]{}))>[{({}<>)<<><>>}({[][]}({}{}))])]]](<{<[({[]{}}([]<>))({{}[]}<()[]>)]{{ +<{[<{[<<<<[<[<{}()><<>>](<()>({}()))>{[<<>[]>{<><>}](({}()))}]{{((()<>)((){})){({}[])<<><>>} +({<{[({([{({<<<><>>([]<>)>(<[]()>[{}()])}<[(()())<()()>][{{}{}}]>)}])(({{(<{(){}}<{}()>>[<<>()><{}<> +{{(({[([<((<{<{}[]>{<>()}}[[<>{}][()<>]]>))[[<{[[][]][[][]]}[<[]>(()[])]>{<[{}[]]{<>{}}><<{}()>[{ +<([{{[[<{{[[{{<>}{{}[]}}(([]())[<><>])][[<[]{}>([]{})]{({}){<><>}}]]<<[<[]()><{}{}>][{()}[<>[]]]>{<<<>{}>(<> +{[[[([[(<<[{<<<>()><()[]>>}][<[<[]{}>(<><>))[<[]<>>[<>[]]]><<{[]()}{{}<>}><{<>}<<>{}>>>]><{<([() +<((<[<[([(({{{{}<>}{()[]}}{[<><>](()())}})>{<(((())({}[]))[{{}<>}{<><>}]){<[{}{}]{<>{}}>({() +[{[<<({({{<[[[[]<>]<<>()]]]([[<>[]]<<>{}>]<{[]<>}>)>}}{[[<[{[]{}}<{}[]>](((){}){<><>})>{<[[][]](<>())> +<[[{{[(<{<(([[(){}]{<>())]))[<[<{}[]>{{}[]}][{()<>}[[]<>]]>{{<<>{}><[]<>>}[([]<>)[[]]]}]>}<<<<{[()< +<(<<{{(<<({<{<[]()>}({[]()}[()<>])>(([()()][{}<>])<<(){}>{[][]}>)}(<{{[]{}}{<>()}}[{()<>}(()<>)]>))((({[{}][[ +{<<<{({{<([[<{<>{}}[()()]><[<>[]]>][<<<><>>>[(<><>)<<>()>]]]([({(){}}[<>()])]<<<<>[]>>({{}[]}[()[]])> +[{<[{[[[({(<<[()[]]>{{()<>}{<>()}}>)[({[[][]][{}<>]}<<[]{}>[()<>]>){[<<>{}>{{}[]}](([]{}){[][]})}]}{{[( +{(<<<{{<[({([({}[])[{}()]]{(<>{})<{}{}>})(<(<>())>({()<>}<[]{}>))}<{<([][]]{()()}>}<<(<>()){[][] +((<{{[{{[([({[{}()]}[{()<>}(()<>)])]([([<><>]<<><>>)<{[][]}<<>[]>>]((<<>{}>({}<>))([[]()]<{}()>))))]} +[(<<<{<{(({(<<[]{}>><[[]{}][()()]>)[(({}{}}[<>[]])[({}<>){()[]}]]}))[(<<<{[]<>}>{[(){}][()[]]}>>[{[([]<>)([] +({({([<([{([[{[][]}{{}[]}]<[<>[]]({}())>])}(({<{()[]}{[]{}}>{({}())<{}[]>}})({{{{}[]}<{}()>}}))][[[[ +([<[<{<[[<{[((<>())(()))[<(){}>{{}[]}]]{<{()[]}{[]()}><<<><>>>}}(<{[()<>]<<>()>}>)><{(([<>()]({}<>))([ +[<[(({[<{{[[((())[<>[]])(<[]<>><<>{}>)][{{<>()}<()<>>}[{{}()}([][])]]]{{<<[]()>>[<{}()>[<><>]]){[{<>() +[(<([[<{{[(([<<><>>(()())](([][]]{<>()}))[<<[]<>><()()>>[({}<>){()<>}]]){{<(()[]){()[]}>}<(< +(<[{[<{[[{{([[{}()]<{}()>]<[()[]](()())>)[<[{}{}][[]()]><[{}<>]{{}<>}>]}}{{[{[{}<>][[][]]}<({}()){[]{}}>] +({{<[{<<<<[<<[(){}](<><>)>({{}()}{<><>})>}[({({}<>){<>{}}}<[()<>][(){}]>)[{(()<>)({}[])}]]> +<{<({<([[((<[{[][]}{<>()]]>{<([][])[[]<>]>[(<>{})[{}()]]})[{[({}())[[][]]]{{[]()}}}<[((){})[[] +<<<({{[<(<<{(<[][]>(<>()))({()[]})}[[<<>[]>({}[])]{[[][]]}]>{(<(())<{}<>>>(([])[<>{}])){(<<><>>[[][]])}}>(<[[ +[<<({[[(<[[[{<[]{}>{()[]}}<[<>()]>](<{[][]}<<>()>><[[][]]([]())>)]](({{{{}()}{<>[]}}}<({[][]}[ +<{[({{{<[(({<({}{})[[]<>]>(({})(<>{}))}[{<{}()>[[][]]}]))]>{<{{{([{}{}]({}{}))(<[]{}>({}[]))}{<{{}()}({}<>) +({{<((({({<[{[<>{}]([][])}]<[{[]<>}]{[[]()][[][]]}]>[{({{}{}}<[][]>){{(){}}}}]})<[(<<({}())<{}()>>({<>}{()()} +<{{{[(({([{<{<[]<>><<>[]>}>[[<[]{}>{()()}]<<(){}>>]}{[{((){})(<>())}<([][])}]}])[({<<{{}[]}>><{{<>()} +(<<<<<<[{{{[[{{}<>}(<>)](<[][]>({}()))]}<<[(<>[])(<>[])]({<>[]}<<>{}>)>{{{[]<>}({}<>>}([<><>]{<>[]})}>} +{[({<{{[({[[{[{}[]]{{}}}]({<{}>{()}}(({}{})({}[])))]{({{[]<>}{()[]}}<[{}<>][[]()]>)[{((){})(<><>) +{{<{{{[({(<{{{{}[]}{[]()}}((<>[])([]<>))}[{{<>{}}([]{})}{[[]<>]<[]<>>}]><{{(<>)}({[]}[()<>])}{<[[] +((<{{{{(([(<{{{}()}{<><>}}>)]{([{<<>[]>{<><>}}<[[][]]<()[]>>])({({[][]}<[][]>)[[[]{}]{[]<>}]})}))({{[ +<<{<([{[{[<<<[()()]>[(<><>)[()<>]]>({[{}]<{}>}<{{}()}<[]{}>>)>][<[{<{}}}{[()<>]{<>()}}]([([][]){ +(({<([[[({{(({[]<>}[()[]])[({}{})<()<>>))<(([][])<<>[]>){<[]<>>}>}(([<<><>>[{}<>]]{<[]()>{<><>}})([<<><>>( \ No newline at end of file diff --git a/advent_of_code/2021/d10/main.cpp b/advent_of_code/2021/d10/main.cpp new file mode 100644 index 0000000..9407209 --- /dev/null +++ b/advent_of_code/2021/d10/main.cpp @@ -0,0 +1,163 @@ +#include + +using namespace std; + +enum HOOKIES { + // PARENTHESIS = 3, + // BRACKET = 57, + // ACCOLADE = 1197, + // POINTY_BRACKET = 25137, + + PARENTHESIS = 1, + BRACKET = 2, + ACCOLADE = 3, + POINTY_BRACKET = 4, +}; + +unsigned int line_score_corrupted(const string& s){ + stack chars; + unsigned int score = 0; + + for(auto c : s){ + if(c == '(' || c == '[' || c == '{' || c == '<'){ + if(c == '('){ + chars.push(PARENTHESIS); + } else if(c == '['){ + chars.push(BRACKET); + } else if(c == '{'){ + chars.push(ACCOLADE); + } else{ + chars.push(POINTY_BRACKET); + } + } else if(c == ')' || c == ']' || c == '}' || c == '>'){ + if(chars.empty()){ + score = 0; + break; + } + + if(c == ')'){ + if(chars.top() == PARENTHESIS){ + chars.pop(); + } else{ + score = PARENTHESIS; + break; + } + } else if(c == ']'){ + if(chars.top() == BRACKET){ + chars.pop(); + } else{ + score = BRACKET; + break; + } + } else if(c == '}'){ + if(chars.top() == ACCOLADE){ + chars.pop(); + } else{ + score = ACCOLADE; + break; + } + } else{ + if(chars.top() == POINTY_BRACKET){ + chars.pop(); + } else{ + score = POINTY_BRACKET; + break; + } + } + } else{ + break; + } + } + + return score; +} + +unsigned int line_score_missing(const string& s){ + stack chars; + + bool corrupted = false; + + for(auto c : s){ + if(c == '(' || c == '[' || c == '{' || c == '<'){ + if(c == '('){ + chars.push(PARENTHESIS); + } else if(c == '['){ + chars.push(BRACKET); + } else if(c == '{'){ + chars.push(ACCOLADE); + } else{ + chars.push(POINTY_BRACKET); + } + } else if(c == ')' || c == ']' || c == '}' || c == '>'){ + if(chars.empty()){ + corrupted = true; + break; + } + + if(c == ')'){ + if(chars.top() == PARENTHESIS){ + chars.pop(); + } else{ + corrupted = true; + break; + } + } else if(c == ']'){ + if(chars.top() == BRACKET){ + chars.pop(); + } else{ + corrupted = true; + break; + } + } else if(c == '}'){ + if(chars.top() == ACCOLADE){ + chars.pop(); + } else{ + corrupted = true; + break; + } + } else{ + if(chars.top() == POINTY_BRACKET){ + chars.pop(); + } else{ + corrupted = true; + break; + } + } + } else{ + corrupted = true; + break; + } + } + + unsigned int score = 0; + if(!corrupted){ + while(!chars.empty()){ + auto h = chars.top(); + score = score * 5 + h; + chars.pop(); + } + + return score; + } + + return score; +} + +int main(){ + ifstream input_file("input.txt"); + string line; + + unsigned int total_score = 0; + + if(input_file.is_open()){ + while(getline(input_file, line)){ + // total_score += line_score_corrupted(line); + + total_score += line_score_missing(line); + } + } + + cout << "Total syntax score: " << total_score << endl; + + return 0; +} \ No newline at end of file diff --git a/advent_of_code/2021/d10/test.txt b/advent_of_code/2021/d10/test.txt new file mode 100644 index 0000000..2f182d8 --- /dev/null +++ b/advent_of_code/2021/d10/test.txt @@ -0,0 +1,10 @@ +[({(<(())[]>[[{[]{<()<>> +[(()[<>])]({[<{<<[]>>( +{([(<{}[<>[]}>{[]{[(<()> +(((({<>}<{<{<>}{[]{[]{} +[[<[([]))<([[{}[[()]]] +[{[{({}]{}}([{[{{{}}([] +{<[[]]>}<{[{[{[]{()[[[] +[<(<(<(<{}))><([]([]() +<{([([[(<>()){}]>(<<{{ +<{([{{}}[<[[[<>{}]]]>[]] \ No newline at end of file diff --git a/advent_of_code/d2/2.txt b/advent_of_code/2021/d2/2.txt similarity index 100% rename from advent_of_code/d2/2.txt rename to advent_of_code/2021/d2/2.txt diff --git a/advent_of_code/d2/Cargo.lock b/advent_of_code/2021/d2/Cargo.lock similarity index 100% rename from advent_of_code/d2/Cargo.lock rename to advent_of_code/2021/d2/Cargo.lock diff --git a/advent_of_code/d2/Cargo.toml b/advent_of_code/2021/d2/Cargo.toml similarity index 100% rename from advent_of_code/d2/Cargo.toml rename to advent_of_code/2021/d2/Cargo.toml diff --git a/advent_of_code/d2/src/main.rs b/advent_of_code/2021/d2/src/main.rs similarity index 100% rename from advent_of_code/d2/src/main.rs rename to advent_of_code/2021/d2/src/main.rs diff --git a/advent_of_code/d3/3.txt b/advent_of_code/2021/d3/3.txt similarity index 100% rename from advent_of_code/d3/3.txt rename to advent_of_code/2021/d3/3.txt diff --git a/advent_of_code/d3/Cargo.lock b/advent_of_code/2021/d3/Cargo.lock similarity index 100% rename from advent_of_code/d3/Cargo.lock rename to advent_of_code/2021/d3/Cargo.lock diff --git a/advent_of_code/d3/Cargo.toml b/advent_of_code/2021/d3/Cargo.toml similarity index 100% rename from advent_of_code/d3/Cargo.toml rename to advent_of_code/2021/d3/Cargo.toml diff --git a/advent_of_code/d3/src/main.rs b/advent_of_code/2021/d3/src/main.rs similarity index 100% rename from advent_of_code/d3/src/main.rs rename to advent_of_code/2021/d3/src/main.rs diff --git a/advent_of_code/d4/4.txt b/advent_of_code/2021/d4/4.txt similarity index 100% rename from advent_of_code/d4/4.txt rename to advent_of_code/2021/d4/4.txt diff --git a/advent_of_code/d4/Cargo.lock b/advent_of_code/2021/d4/Cargo.lock similarity index 100% rename from advent_of_code/d4/Cargo.lock rename to advent_of_code/2021/d4/Cargo.lock diff --git a/advent_of_code/d4/Cargo.toml b/advent_of_code/2021/d4/Cargo.toml similarity index 100% rename from advent_of_code/d4/Cargo.toml rename to advent_of_code/2021/d4/Cargo.toml diff --git a/advent_of_code/d4/main.cpp b/advent_of_code/2021/d4/main.cpp similarity index 100% rename from advent_of_code/d4/main.cpp rename to advent_of_code/2021/d4/main.cpp diff --git a/advent_of_code/d4/src/main.rs b/advent_of_code/2021/d4/src/main.rs similarity index 100% rename from advent_of_code/d4/src/main.rs rename to advent_of_code/2021/d4/src/main.rs diff --git a/advent_of_code/d5/5.txt b/advent_of_code/2021/d5/5.txt similarity index 100% rename from advent_of_code/d5/5.txt rename to advent_of_code/2021/d5/5.txt diff --git a/advent_of_code/d5/main.cpp b/advent_of_code/2021/d5/main.cpp similarity index 100% rename from advent_of_code/d5/main.cpp rename to advent_of_code/2021/d5/main.cpp diff --git a/advent_of_code/d6/main.cpp b/advent_of_code/2021/d6/main.cpp similarity index 100% rename from advent_of_code/d6/main.cpp rename to advent_of_code/2021/d6/main.cpp diff --git a/advent_of_code/d7/main.cpp b/advent_of_code/2021/d7/main.cpp similarity index 100% rename from advent_of_code/d7/main.cpp rename to advent_of_code/2021/d7/main.cpp diff --git a/advent_of_code/d8/8.txt b/advent_of_code/2021/d8/8.txt similarity index 100% rename from advent_of_code/d8/8.txt rename to advent_of_code/2021/d8/8.txt diff --git a/advent_of_code/d8/main.cpp b/advent_of_code/2021/d8/main.cpp similarity index 100% rename from advent_of_code/d8/main.cpp rename to advent_of_code/2021/d8/main.cpp diff --git a/advent_of_code/d8/test_text.txt b/advent_of_code/2021/d8/test_text.txt similarity index 100% rename from advent_of_code/d8/test_text.txt rename to advent_of_code/2021/d8/test_text.txt diff --git a/advent_of_code/d9/9.txt b/advent_of_code/2021/d9/9.txt similarity index 100% rename from advent_of_code/d9/9.txt rename to advent_of_code/2021/d9/9.txt diff --git a/advent_of_code/d9/main.cpp b/advent_of_code/2021/d9/main.cpp similarity index 100% rename from advent_of_code/d9/main.cpp rename to advent_of_code/2021/d9/main.cpp diff --git a/advent_of_code/d9/test.txt b/advent_of_code/2021/d9/test.txt similarity index 100% rename from advent_of_code/d9/test.txt rename to advent_of_code/2021/d9/test.txt diff --git a/advent_of_code/2022/1/main.cpp b/advent_of_code/2022/1/main.cpp new file mode 100644 index 0000000..e69de29