From 0cadb2319cf7b937918df7071a810d28d769a465 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Fri, 7 Jan 2022 12:15:26 +0100 Subject: day09 & day10 --- 2021/day09/day09 | Bin 0 -> 113360 bytes 2021/day09/day09.cpp | 101 ++++++++++++++++++++++++++++++++++++++++++ 2021/day09/day09_input.txt | 100 +++++++++++++++++++++++++++++++++++++++++ 2021/day09/day09_input_ez.txt | 5 +++ 2021/day09/makefile | 2 + 2021/day10/day10 | Bin 0 -> 97680 bytes 2021/day10/day10.cpp | 88 ++++++++++++++++++++++++++++++++++++ 2021/day10/day10_input.txt | 94 +++++++++++++++++++++++++++++++++++++++ 2021/day10/day10_input_ez.txt | 10 +++++ 2021/day10/makefile | 2 + 10 files changed, 402 insertions(+) create mode 100755 2021/day09/day09 create mode 100644 2021/day09/day09.cpp create mode 100644 2021/day09/day09_input.txt create mode 100644 2021/day09/day09_input_ez.txt create mode 100644 2021/day09/makefile create mode 100755 2021/day10/day10 create mode 100644 2021/day10/day10.cpp create mode 100644 2021/day10/day10_input.txt create mode 100644 2021/day10/day10_input_ez.txt create mode 100644 2021/day10/makefile (limited to '2021') diff --git a/2021/day09/day09 b/2021/day09/day09 new file mode 100755 index 0000000..1e91342 Binary files /dev/null and b/2021/day09/day09 differ diff --git a/2021/day09/day09.cpp b/2021/day09/day09.cpp new file mode 100644 index 0000000..a034659 --- /dev/null +++ b/2021/day09/day09.cpp @@ -0,0 +1,101 @@ +#include +#include +#include +#include +#include + +#include "../utils.h" + +int xytoi (int size, int x, int y) { return size*y + x; } +int itox (int size, int i) { return i % size; } +int itoy (int size, int i) { return i / size; } +bool oob (int sizex, int sizey, int x, int y) { + if (x < 0 || y < 0) return true; + if (x >= sizex || y >= sizey) return true; + return false; +} + +std::vector> get_dirs() { + std::vector> dirs { + { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } + }; + return dirs; +} + +bool is_min (std::vector grid, int size, int i) { + int x = itox(size, i); + int y = itoy(size, i); + for (auto dir : get_dirs()) { + int j = xytoi(size, dir.first+x, dir.second+y); + if (!oob(size, grid.size()/size, dir.first+x, dir.second+y)) + if (grid[j] <= grid[i]) + return false; + } + return true; +} + +std::vector flood (std::vector grid, int size, int i) { + std::vector visit ; + std::vector q { i }; + while (q.size() > 0) { + int x = itox(size, q[0]); + int y = itoy(size, q[0]); + if (std::find(std::begin(visit), std::end(visit), q[0]) == std::end(visit)) + visit.push_back(q[0]); + q.erase(std::begin(q)); + for (auto dir : get_dirs()) { + int j = xytoi(size, dir.first+x, dir.second+y); + if (std::find(std::begin(visit), std::end(visit), j) != std::end(visit)) + continue; + if (!oob(size, grid.size()/size, dir.first+x, dir.second+y)) { + if (grid[j] < 9) { + q.push_back(j); + } + } + } + } + return visit; +} + +int main (int argc, char * argv[]) { + std::string raw; + std::getline(std::ifstream(argv[1]), raw, '\0'); + std::vector lines; + split(lines, raw, "\n"); + + int size = 0; + std::vector grid; + for (std::string line : lines) { + if (line.size() == 0) continue; + size = 0; + for (char c : line) { + grid.push_back(std::stoi(std::string { c } )); + size++; + } + } + + std::cout << "lowpoints: "; + std::vector lows; + int sum = 0; + for (std::size_t i=0; i isles; + for (auto low : lows) { + auto visit = flood(grid, size, low); + isles.push_back(visit.size()); + } + std::sort(std::begin(isles), std::end(isles), std::greater()); + + int res = isles[0] * isles[1] * isles[2]; + std::cout << "three largest basins multiplied: " << res << std::endl; + return 0; +} diff --git a/2021/day09/day09_input.txt b/2021/day09/day09_input.txt new file mode 100644 index 0000000..c064a7b --- /dev/null +++ b/2021/day09/day09_input.txt @@ -0,0 +1,100 @@ +5796798621237995498765434567987542999765679987545679109878999877899789876532123456998999876887899921 +4645976434456789349654321298997679898654698987635678998767897656789698765432012347897899865676798799 +3234987545978993298795410989998989789543256897646789498756789546896579877842123456976789954345985678 +4356798679989999019987329878999798679765345689856991296545890134789467998956899967895698643239874579 +6467999789999898934976598967987676568996457999967999987636789345691346789769987898934987651098763456 +7598997999987796899989987959876543456789569898998998765125678956910298899898776799123998862987652345 +8789876789865685578999876645987665567998689656789876554034899999891989998987564679099789879876543456 +9898765498974324456799865534598786788998798645889985432126954987789878987654323567988698989987664678 +9989997987543212367987654323459897899549895434569876556437899876599967996543212459876587898998798789 +9877989997662101456798765434567998967932987624778989787548999989679459987687301349875456967899899893 +8765678998983232367899896765788939346891295434999999899659879699894349899796532656954344756910923964 +9874789019894343456789949878999321235799987545678945998778964578942139769898543769843212345891949765 +7965678998765764567893433989876542346987898656789236799889653989943298652999678989754523456789898976 +6598789109976975698921012398999763457896559867997647989998799899874569541098799798765676579896687897 +5439898929989989789962123457899894568989435998998799878999989798765798432149898649987787899965456989 +5212987898999999899854336568999989879979326569109989567898879689878987544234995434599898999874345679 +4309875987999876998765687679989878998765412458929875467987854599989698955679989323459979899993214589 +5996954676799984329877788989878969899874324567899765359876743489996549877789878912398767789984323456 +9875432545789743212989899998967659789985595678998868249965312679865435998898767899598954698765467567 +2994321036897654101996936987654543679999989789997854198764301569979423459999954678997643789978578978 +0987432128998763219875424698763212478998978999876543298773212458998901267898767889598732345988789989 +9876544346789979329876512349998401569897569234987994987654343457897892478999878993349891234899998695 +9989875679899898939984701459886212398786456946799889998795464567896789989896999321234989345678987544 +9997987889998797998743212598765323987654397899989778999989978679945698999765678930349878956999898433 +8986798999987676789655329679876439876541289998878656899867898791239956799954345959499867897899765321 +7845679219878565678976598999987556998732378997667545798656789892398745999765237898987656789998654310 +6434798998765454567897987898798677899543467896553234987545878989499636878992156987975345899219964324 +0123987999874343456789876799549789987654598998421056989434767879976521767989249876543234998909878434 +4339876798955102367898985678939891099967899876542159875323854568965410156978956997684456797899989545 +5498765986543234488987894799012999129878999987653249986210123467894321249769767898795867956789199656 +6599754397654545589996789899993998949999998799767998975351237998995432398758998989986788946999098789 +7988732198765657678975698999879876898946999544979877989876456789987643459647899876097899534878999899 +9876546019878767889984567899968765667939896532989966592987887893298754598756789965198997323456799989 +0998757898989899992099789988754543457898789540199854301298998984129866789998999954249986412345899878 +1299898987699954954299999876543212348987698921598763212349999873234977995679439765356897601234988767 +2989999876569999895989986987654103467896567892349854334568989964345698934678921976897996532349875756 +9879899988698988789878995498976215989995456789498999965689879899456789323567890197998987656756994345 +8765677899987677697667896329865423499989997995987878897798768778968895438678991298969398967899873201 +8654546789766563459548994219876534578977789104986567789949654567899976657899789349543219988932965412 +8643437899854312998435689101987645689665679323975345678959868778957987798934679959654301299549876723 +6532126778969409876424578912498756796553568939863203456899979989646799899012567898976432358956987894 +8544434567998912998535689843569867989432459949954212568999989594535798989123467987976563567969799985 +9655566789897893479697897654567979879421267898767343467898795443123497679935679876899674789997659876 +9776789998656799567989998765678998967992349929876556578987654321012989567896798765678985999876642989 +9988899875434678979878999879889987657889458919997967689798865452199867456987987654567896798765431096 +8799943989545789999868799989999876545678967898789898797659979874987654347899999753459987979876532145 +7679969998656789987657678994323965432789979987679789896535989995998321234568939894567899764987687236 +7567898959767893976543467995909876645678989996545678965423599989899754359679421986789968973199875345 +3467987644978912987784989879899987856789999987434569653213679876789866468789439898993459792012989466 +6569999533989999798896797867789898987897999876424678962102398765898977578996598769322375679933496578 +8678998921296789679987896545698769399986789764312398993923499654567897689398999954201234567894987689 +9799867890145679542998987896789954234995698765101256789894987543458999791249899895312347899995798789 +2988656891237789869879998998996895999876789864212345996789987652377899910299756789436556799989999890 +3977545789347899998767899989434999879989898987423467895678993210466789321987645679987867989767899921 +9865437896556789999946799876545998767999987976534789954589997621245679459876437898798979876545978943 +9976545789697899987834689989699767656899876989675678932679876432556789598943218997659989765434567894 +9989867899989999986545678995987654545998965498797889321996997543457898797654323789943596986546789965 +8896978999879878997668789213986543234987894349898996549875698665678909998965534567892345697656798987 +7645989898765655689779898901987662129876789234989998698954539987899919879877645689931257898767967899 +9869998789964334578995937892397654398945689345678979987643012398967898767998776798890234999898957898 +6998789679892123457894325943498765987834568956889467898952134579656899656549887897789656799999546457 +5987654597651012349975434799579989865423567897992378999763245678947999743435998996549767987989432347 +4398753299843123457896545678992099654512455789209989398754356789439879842124999987638989876678954456 +1239854987653238768998956999989298743101234678998994298765768899598765431029892196547898965466795567 +0123995799768545678969869878979349543213455789997899109976779998789987532139789987656987654345789979 +3235986999879656789756999867668956975434696899986987912987899999894697643298678999987898543234567898 +9945799876998798897645987654456899876595989989765976899998999886989987659987567998998999864365788977 +8799895995439899986534598732367968988989878979954695678919998785468998798766456997899898765479899766 +5678923994323999876545987543478957999976556767893254589101987674378789899854349876799649876678987645 +4567919876214899987689998954989546898765432356789123678919986543245679998765467965678999987789298756 +3467898765436789998998999879995434999896521237895019789998997532135998899977569876789988798992109867 +2369929876545699999987899999876545689943210235994298999997989949239876789989778989899976569993298989 +3458910997676789899876989212987676899656432346789987889886979898949965679999899998998665478989987897 +4567899998787895798765678923598789998789545497899996779765765787898764567878921987999543289567976546 +6878978999898934989894569654589890249899876569999884568954654656989843458967899876998992123458997997 +7989569899919129878989678979678931239964998978998763477943212349879932123458998765876789012567919989 +8991356779909019767678989989899842498643239989987542356799302345965431014568919954345692139898929879 +9410124567898998654567891294998753679654134699876521245678913459876432323589109765457789256799598767 +4321267898987549876899910123987654598763245698776410234569865567997943434578999988767899767895349654 +6532356789876434987898943235698765679854659987654321345678976778999894565689989999878949878943298765 +7656467893987545998967896545699887998767998998765432456889988999998789689789878989999432989752129976 +8767589954899756899459987756989998919879897899876548668994599989987678999898769878997643496543234988 +9879678975798967987598999899878959102998766999988767899123678978986567894987653967898765789759449999 +2989789996987898998987899954969643213459945789799878943239989865454478923986542656949896899898998931 +1299899989776999129976899769878965425678996999656989965398798754342349435965421248956997899987687899 +0467999876545789098865689879989876566789987898768997897987659983210456949878543367899898999876546797 +2378988965434678987674778998999998987893598999879876798965434975672569898987665456789789998695435896 +4499877994323569876523467897988999999912459999989965689896323497883479767999787578995679876564326345 +9987656789212489986313568966767897899106598989999984878789212598965998956799898989664868975432101234 +8798878994323478965423459954456986798919987678999873165678943679879876545689939996543459876875212345 +9659989765434568976796567893299765987898765569898762054567894578998765434696549987654667998994323476 +8934599879876899997898879954987654496987654346789943123489965679539854323589998998767898989889456567 +7895678998987899998999998769876543345798765767898894344567896789329875434567897689998999878778967678 +6796989987698969799998789878998632134899878998946799465679987898919987645679976578999098767669898799 +5789995799549347689987678999986721023999999769434878987989998967898998767989787459989298653456789910 +4567894698432134567988566789875432335698798653212967999997859456987679878998643212578987832345679891 +3779992976553235679977455698998765487987689864343458999876543237897569989797652101459876543456789789 +9889689987664346798765323456789887569876598765454569986987652145789698795698768892368987956567895678 +4994567899865457999974313345699998798765439879875678955698767234999987654229878765456799767878934589 +2123456999876567899875101256789109999984321989989899543249878945678996542101989877667899878989123699 diff --git a/2021/day09/day09_input_ez.txt b/2021/day09/day09_input_ez.txt new file mode 100644 index 0000000..6dee4a4 --- /dev/null +++ b/2021/day09/day09_input_ez.txt @@ -0,0 +1,5 @@ +2199943210 +3987894921 +9856789892 +8767896789 +9899965678 diff --git a/2021/day09/makefile b/2021/day09/makefile new file mode 100644 index 0000000..18a7e4a --- /dev/null +++ b/2021/day09/makefile @@ -0,0 +1,2 @@ +all day09.cpp: + g++ -std=c++20 -o day09 day09.cpp diff --git a/2021/day10/day10 b/2021/day10/day10 new file mode 100755 index 0000000..e3b93c6 Binary files /dev/null and b/2021/day10/day10 differ diff --git a/2021/day10/day10.cpp b/2021/day10/day10.cpp new file mode 100644 index 0000000..4fad4ca --- /dev/null +++ b/2021/day10/day10.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include +#include +#include + +#include "../utils.h" + +char map (char a) { + if (a == '(') return ')'; + if (a == '[') return ']'; + if (a == '{') return '}'; + if (a == '<') return '>'; + return 'A'; +} + +bool match (char a, char b) { + if (a == '(' && b == ')') return true; + if (a == '[' && b == ']') return true; + if (a == '{' && b == '}') return true; + if (a == '<' && b == '>') return true; + return false; +} + +int score (char a) { + if (a == ')') return 3; + if (a == ']') return 57; + if (a == '}') return 1197; + if (a == '>') return 25137; + return 0; +} + +long score (std::string str) { + long s = 0; + for (char c : str) { + s *= 5; + s += (c == ')' ? 1 : 0); + s += (c == ']' ? 2 : 0); + s += (c == '}' ? 3 : 0); + s += (c == '>' ? 4 : 0); + } + return s; +} + +bool check (std::string line, std::string &out) { + std::stack stack; + for (char c : line) { + if (c == '(' || c == '[' || c == '{' || c == '<') { + stack.push(c); + } else { + if (!match(stack.top(), c)) { + out.push_back(c); + return true; + } else stack.pop(); + } + } + while (!stack.empty()) { + out.push_back(map(stack.top())); + stack.pop(); + } + return false; +} + +int main (int argc, char *argv[]) { + std::string raw; + std::getline(std::ifstream(argv[1]), raw, '\0'); + std::vector lines; + split(lines, raw, "\n"); + + std::vector repairs; + int sum = 0; + for (auto line : lines) { + if (line.size() == 0) continue; + std::string rep; + bool corrupt = check(line, rep); + if (corrupt) sum += score(rep[0]); + else { + repairs.push_back(score(rep)); + std::cout << score(rep) << " " << rep << std::endl; + } + } + std::cout << "corrupt score: " << sum << std::endl; + std::sort(std::begin(repairs), std::end(repairs)); + std::cout << "repairs score: " << repairs[(repairs.size()-1)/2] << std::endl; + + return 0; +} diff --git a/2021/day10/day10_input.txt b/2021/day10/day10_input.txt new file mode 100644 index 0000000..eec53e5 --- /dev/null +++ b/2021/day10/day10_input.txt @@ -0,0 +1,94 @@ +({<{({([<<{<[<<><>><<>>](<()()>)><{{{}<>}}<<<>{}>[<>[]]>>}{[<<[]{}>[<>()]>[(()[])]]<{{<><>}[[]<>]}{< +[(<[[([[(([<{{[]{}}([][])}<<{}[]>([]{})>><{<()()><[][]>}{[()]<()[]>}>]<{({()()}){[{}[]][<>()]}}[{[{}<>] +{{(<[[(<<<(<<[{}{}]{<>()}><{[]{}}([]{})>>([([][]){{}<>}][<()<>>[(){}]]))<{<(<>())[{}<>]>{{[]{}}<<>{}>}}({< +<([({[<[(([[<(()<>){[]<>}><<(){}>{()()}>]](<(({}[]){[][]})<{<>())[<>[]]>>{{{()<>}{(){}}}{[<>()]<{}[]>} +<(((<{<(<{{[[[()<>]{[]()}]][{<()[]><<>{}>}]}}[<{[{[][]}[<><>]]}{{{(){}}[<>()]}{[[]()]{<>[]}}}>{[({{} +{{({[({(({{[<[{}()]([]<>)><<{}()>[<>[]]>]<<{[]{}}([]<>)>{{<>}{<>{}}}}}{{<<[]<>>{<>()}>}<({[]<>} +(([{[(<(<[[(([()[]][{}()])(([][])<{}<>>))]]>)[<(<{{<<><>>(<>[])}<([]<>)[[]{}]>}((<{}[]>[<><>]){{[ +{{[<<{<<(<([<<[]()>[[][]]>{[()[]]<()[]>}]){(<(<>{})([])>{<(){}>{<>()]}){[<[]()><<>()>](([][ +((<{[{{(<<[(<{<>{}}[<>[]]>{<{}<>>{{}[]}})]>><{([<(<>())[{}()]>{<<>{}>{[]{}}}><([[]()]<[]<>>)(<[]>{()()})>)}>) +{<({{{(<[([<{(<>[])<()[]>}([[]]([]{}))>])[{{[([]){[]{}}]}}{[[{(){}}{<>{}}][[(){}]]]<([<>{}]{{}<>})( +([([{{{[[<<[[(()[])<<><>>]{({}[])}]((([]{})<<>>)({[]<>}[<>[]]))>{(({<>()})([{}[]]<()<>>)){[ +{[<(({[<<{{{[({}[]){<>()}]{[()()]{[]()}}}[{<<><>>{<>[]}}<{()()}<()>>]}({<(<><>)[()[]]>([{}()])}{[(<>())(() +<{{[[<{{(<<{<[{}{}]<{}[]>>[{{}[]}[{}()]]}((<()()>{(){}})<((){})>)>[{<({})[[]{}]>([{}<>])}{{[{}()]}{<[ +[{[<{<[[({([(<{}<>>[<>()])]<<<{}{}>({}<>)>>)<{(({}[])({}<>))}<{<[]>({}<>)}{{()()}([]())}>>}){<[<[[{}<>]< +{(<{{<{<<(<<<[{}{}]((){})>>{<<{}{}>{()[]}>}>)([({(<>())<<>()>>)(<<()[]>(<>())><<()()>({}())>)]{(<[<>< +[{<{[<{([{[({<(){}>([]())}[<<>[]>([]())]){{<(){}>{{}[]}}<[()[]]({})]}](((<{}()>{{}()})))}[[( +<<[{{[<<(<{({{[]{}}{()()}}){<<{}()>({}<>)>(({}<>)[()<>])}}<[[([]{})[<><>]]]((<()()>{<>[]}){{[]{ +[[({[({[([({{<[]{}>{(){}}}{[[][]][()()]}}[{<{}><{}()>}({()[]})]){{[[()<>]<[][]>][({}<>)]}}](<({<{}( +[[[((([((<{{[(<>())[{}[]]]{{<>{}}}}}>))<[[[({{{}{}}(()())})({([]{})[<><>]}[([]{}){()[]}])]<{<[{ +[{[<[{{([[{(({()()}<{}[]>){{()<>}{{}()}})<<<{}[]>>{<<>[]><{}{}>}>}]{{{[{()()}[<>()}]{{{}}[(){}]}}} +[[{[(({[[[[{(<<>()>(<>()))[<{}[]>{[]<>}]}{{{()<>}<()()>}}]<[<([]<>}{<>[]}>]>](((<{()()}<()()>><<<>[]><<> +({[{({(<{((<<[()[]]<()<>>]<([][])>>[([{}()]<{}{}>){<{}{}>(()[])}])[{([<>()]{()[]}){[()[]]}}([{()<>} +[(({(([[{(<{{<[][]>(()()}}[({}[])]}[(<<>[]><()[]>)]>)<{({{[]{}}[()[]]}[<<>()>(()())])}{(((()[])<[]>) +<(<([[({[((((<{}[]>[{}{}]){[{}<>](<><>)})(([()<>]({})){[{}{}]{[]<>}}))[({(()[])<<>[]>}[[()<>]<() +{[(<<({([{[(<<[][]>(<>())>){<[<>()][[]{}]>(({}[])[(){}])}][(({{}<>}))(<[()()]<()()>>}]}{[{<(<> +[{{({<({<(<[[<{}<>>{()[]}][{()()}]]>){[<{{()[]}[{}()]}>([<()[]><{}<>>](<()[]>))]{[<[<><>]{<>[]}>[<() +{[<<[{<<[[(<(<[][]>[()()])>){<(([]()){{}[]})><<[{}()]<<>>>>}}[[([<{}[]><(){}>][({}())[()<>]])[[{<>[] +{((<[{{<{[<[((()<>)<()()>)]>]}>}((([{[[<<>[]>[[][]]]<[[]()]({}[])]]{[([]{}){()()}]}}<((<[]< +{[[({<{<<{<{{{[]{}}}}>}[[{(([][]){<>[]}){{()<>}}}<<<()[]>[{}[]]>>]<[{[()[]]({}{})}{[{}()]}]>]>>}>}< +[{[(<({{(<(([{()<>}{()<>}]{{[]}(()())]))>(<<{[<><>]<()<>>}[(<>{})<<>{}>]>[{{<>{}}{{}[]}}<[< +{{((<[(([<{{([()][(){}])({<>()}[()<>])}[{[{}<>]<()()>}<{{}}([]<>)>>}(<<[[]{}]<[]<>>>[([]()){[]{}}]>((<<>( +(<<<(<([<<({<<<><>>[{}<>]>{<()>([]<>)}}{{(<><>)}<{<>()}{{}()}>})<<<({}{})<[]<>>>>>]{({({[][]}[{}()])([<>()]( +([(<<<(<(([([{<>{}}<(){}>](<{}<>>[{}{}]})][([<()>{{}[]}](<<>()><()[]>))[[{<>()}[<>[]]]{<<>[]> +(<{[[<<<({[<<([]())[()()]>([()[]]{<>{}})>]})[[{<[{<>()}({}{})><(()<>)([]{})>><<<<>()><<>() +[[[{(<[[((<[{<<>[]>({}[])}<[{}{}]{[]<>}>]<{({}{})}{[{}<>]{<><>}}>>([{[[]<>](()<>)}{{<>{}}(<>[]))]{[{{}{}}]}) +[(<([[[{<[[<((()()){[][]})>((<{}[]>[()<>])<([]()){<>[]}>)]<<{<<><>>}{{(){}}}>>]<{[<<(){}>({}<>)><<<>()>([]<> +[<((<<[<{[{[{[()[]]{()<>}}(<<>()>[<>()])]}{<[[(){}]{(){}}]{[()]{<>[]}}>{{<[][]>[()()]}[(<>{ +[({{([([{[[([<<>{}>[[]()]]({{}()}))][<{{()[]}}<<{}{}>>><[[{}[]][<>()]][{{}[]}(<>{}))>]][{((((){ +((<<{(([[[{{<[()[]]({}())>}<[{(){}}]<({}{})<()[]>>>}{((<()<>>([]<>)){[()][()[]]})([{()}<[]{}>]<(<><> +<<<<[([<<(({<[[]()]<<><>>>({[][]})}{([<>{}]<<>()>){{[]{}}}})){[[[[[]{}][(){})]{(()[])(()<>)}]{{[[]<>][{}( +[({{([<{({{[{(()[])<<><>>}(((){})[<>()])>}{{{{{}<>}<{}[]>}{[(){}](()[])}}}}([(([<>{}](<>[])) +([(<({{(<<[([[<>][<>()]])<[{()[]}([]{})]{[()<>][[]{}]}>]><<{[{<><>}<()()>]{{<>[]}>}>>><[<{{ +({{(([({{<[<[{{}{}}{{}<>}]((<>{})[[]<>])>(((<><>)<{}()>){{{}{}}{{}{}}})]({<{{}}([][])><<[]{}> +[(<{({{(<<<(<[{}[]]{(){}}>(([]()){<>[])))[{{[]{}}{()()}}{[<>{}][<>]}]>[((<{}<>>[<>[]])[({}[])<[]{}>])[<[{ +[(<<<[<<({{{[[(){}]]{<<>{}>{()[]}}}{({<>{}}{[][]})}}{<([()[]]<{}<>>)([{}()]({}[]))>[(<<>()>{[]()})]}}{([{{( +{[{{(({[{<{{[[()<>]<[]<>>]({{}{}}[{}{}])}{(<<>[]>{[]})[[[]{}]{()<>}>}}{<<{{}{}}(()[])>>{{[[]()] +[<[[{(([<<[<[([][])<[]{}}]{<(){}>}>(<<()<>><[][]>><<{}[]>[{}()]>)]><([([[]<>](()[]))[(()<>)<(){}>]][({ +<{{<([<([{{{(<[]{}>[[]{}])[{<>{}}([])]}}[<[<<><>>({}<>)]{((){})[[]<>]}><[{()[]}<<>{}>]{{()() +{[<<<([{([{<<(()[]){{}{}}>[(<>{}){{}()}]><[[{}<>][[]()]](<{}()>([]()))>}]){{<{<[()<>][<>()]>< +<{[<<[([[{[({[[]<>](<>[])})({([]<>)<[]()>}<([]<>)[<>[]]>)]}[[{[{()<>}{<>{}}][<[]{}>(<>[])]}<({[]<> +[[[[([({(((<<[()<>]>[(()())]>{[{{}()}[[]()]]{[<>()]([][])}})))}(<({(({()[]}[<>()]))<[[()<>]]<{{}()}[()<>] +{[([([<[(<<[<[[]()]<[]<>>>][{<[][]>[<>()]}{({}<>)<()[]>}]><{({<>()}{<><>})<{(){}}({}{})>}<{( +<<({[<<{(<[<({{}[]}{<>[]})[<()()>]>(([<>()][<><>])(<<>{}><()[]>))](<[<{}<>>[{}[]]]({{}{}}( +[<<{<(([<[{(([()<>]({}{})){<<>[]>[()()]})({([])(<>())}[{[][]}[{}[]]])}{({(()())[()[]]}({[]<>}([][]))) +((({<[{([(<[(<[]()>)](<[{}()]<[]{}>>(({}())<()[]>))>)[(<[([]<>)(<>{})]>)]][({({[()[]]{<>}}[[[]{}]{()[]}])([<< +[[[(({[<[((({([]){<>{}}})[[{()[]}[{}[]]][{[]<>}]])<<(<[]{}>[<>[]])[<[][]>[{}[]]]>>)[([{{<><>}[[][]] +({<(({{[{{<[((<>())(<>[]))<<<><>>((){})>]([<[][]><{}{}>][[{}()]<<>()>])>((<[[]()]([][])>[<{}[]>{ +(({<<([[<[[{<[()()]<[][]}>[{(){}}[{}<>]]}(<{{}<>}{[]<>}>{<(){}>{<><>}})]<<{<<>[]>[<>[]]}{{ +<[{([<[({<((<[{}()]([]<>))[(()[])])((({}{})<()<>>){(()<>)}))>{[<<[<>{}][(){}]>{<<><>>(<>[])}>{[ +{[([[[{{<<[<<<()()>(()<>)>[({}{})[<>{}]]>([[[]<>]]{<<>>[[][]]})]><<[{(()[])][<()>[{}[]]]]<([{}{}][()<>])( +{(({{<<((<{<<<[]{}>{{}()}><<<>()><()[]>>><<[<>[]]](({}[])[[]{}])>}[[({<>()}{()}){[[]{}]({}())} +<[[{<[({<([<<<()<>>>>([[[]()]{<><>}](<<>[]>[<>]))])(({({[]{}}){{{}()}{(){}}}}[{(()<>)[[]()]}[{<>()}{[][]}]])) +{<[[([{<<<{{[<[]{}>[[]<>]]{({}())<[][]>}}<<<{}{}>>({(){}})>}([{({}())}<([]())[()()]>])>({{[[<>()]{{}{ +<{(<[{[[{[<<<{(){}}[<>{}]>{{{}[]}<<>()>}>{[{[]()}<<>>]{<[]{}>[()()]}}>][[[{<<>())[[]<>]}<(<> +[{{<<{{([(<<{{{}}[()]}<(()())(<>())>>(<{[]()}[[]<>]>)>[((<()()><[]{}>}({[]<>}))(({[][]}{[]<>})<(()[])(()[] +([(<<[<{({[[[(()<>)<{}()>]{[{}()]{<>{}}}]{(<(){}>{{}[]}){<<><>><{}[]>}}]}<{[[[()()]{{}{}}]] +{<(((<({<((([<(){}>]){{{<><>}{{}()}}})({<[[]{}]>{({}())}}))>})([[<<<{[{}[]]{[]{}}}<{()<>}({}[])>>>{[ +{([[{[[[<<<({{()<>}}(<[]<>>[<><>]))[[[[]<>][{}()]]]>{<<[<>()][[][]]](<{}{}>{[]{}})>[<(<>{}){<><>}>([{}[]] +[[{(<{{{<(<{[[{}()](()[])]}<<{(){}}[()[]]>{[()()]([]())}>>)>[(<<<{[][]}>>[{([][])[(){}]}[(< +<{[(<{<{(<<{<{()[]}(()[])>(([]<>)([]()))}>{((({}[]))<{[]()}{{}()>>)<{<(){}>}<{<>()}<()()>> +<(<[{{[[{<{[{[<>][<>[]]}]{[(<>[])][<{}{}>{<>}]}}(({[()<>]{[]<>}}<{(){}}[[]{}]>)([[<><>]<()()>]<({}[])([]()) +{(<{[{[{({{(<<<>{}>><({}())(<>())>)}}{(<<<(){}>{(){}}>(<{}()>(<>()))><[{<>()}{{}()}][{[]<>}(()())]>){<[{{}[] +{[((((({<(([(<[]<>><[]<>>)<<{}()>>](<{()[]}(()<>)>{{{}{}}([]{})})))[<[{([])[<>]}(([]())<{}{}>]]{ +(<{[((([{(<<{(()<>){{}[]}}>><<<({}<>)[[]()]>{(<>[])[()()]}>{{{<><>}([]())}}>)[{(([[]()][<>( +<[<<<[(<[[(<<([]{})>([[][]][{}{}])><[<<>[]>[{}[]]]<[<>][()()]>>)][[<<{()[]}(<><>)><<()()>[()<>]>>][{[{[]() +<<{([[<[[<[({[<>[]](()<>)}{({}[]){()[]}}){({{}[]}(<>()))}]<[[<[][]>[[]<>]]<[{}<>]<[]{}>>)>>]< +[((([[{<<[[<{{{}[]}[()<>]}>(<<{}{}>[(){}]>({<>[]}<{}<>>))][<{[{}<>]{[]}}>({[{}{}}[[][]]})]](({[{[][]}]{[{} +[([{<[[{<((<<{[]<>}(()<>)>>{(<<>{}>(()<>))}))[(<[[[][]][<>{}]]{[()[]](()())}><({{}{}}}[({}())]> +{{[({<(({{[({{[]()}<()<>>}{([]()){[]{}}}){[<<>>[<><>]][<{}<>><()[]>]}][{<({}{}><[][]>>{{{}()}<(){}>}}]}}))>}< +{[{[<{{({[({[[{}()][(){}]]{{[][]}<<>()>}}[[(<>[])<[]{}>]((<>[])[{}()])])]})}}>{({{<([{<([]())[{}{}]>{ +<{{[{<{<<{{({<{}[]>[(){}]}[[<>()]{(){}}])}}[{{[(()<>)(<><>)]<{()<>}{<>()}>}{({[]()}{{}()})<{{ +((((([{{<<[<({()<>}<<>{}))<{{}<>}(<>[])>>{<{(){}}[{}[]]>}]{<<[{}{}]>{{()()}[{}<>]}>}>>([[({(()())<() +(({{[[<[[<<<<<[]()>[{}<>]]>>({[<<><>><{}()>]{{(){}}[<>{}]}}[[([]<>)({}<>)]])>{<[[<{}[]><{}<>>][<<>[]>]](<<[] +<[<([<<[([[[[<{}[]><()>][(<>{}){[]}]]{({()[]}[<>{}])}]([((<>[])(<>[]))[{<>[]}{[]<>}]][(([]{})({}<> +<((<{{({{([<([<>{}](()()))<<(){}>[<>[]>>>({<<>>([]{})})]<[[([]())<<>>]{{<>{}}(()<>)}]>)<[(((<>)<{}<>>)({<>( +{({<({<<[[{[((<>())<()<>>)<(<>[])((){})>]({{[]()}[{}()]}[[{}{}]<{}[])])}({<[(){}](<><>)><{()<>}[{}[] +<[(<<[((([(([[[]<>][<><>]]{{{}{}}[{}[]]}){(({}())<[]{}>)})<(<(()[]){()()}>{<()>[[]{}]}){{[[]{}]([]< +{(<(([{[[<[[[{<>{}}{[]{}}]({(){}})]<[[()()]][[{}[]]]>]{<<{{}{}}[{}{}]>>[(<{}()>([]{}))(<(){}>{<><>} +((<<({({<{<<[<[]{}><()[]>]<(<>()){()[]}>>>}{(((({}<>)({}()))<{[]{}}<<>[]>>)<({[][]}<(){}>){ +[[<{((({{{(<{[[]{}}{{}}}<{[]{}}<()>>>{<{{}[]}<[]()>>{[()[]]{[][]}}})([{[[][]]}(([]{})<<><>>)][(<[][]>{{} +(<({[{[(<<(((([]())[<><>]}([<><>]))<[[()<>]<<><>>]{<[]()>{()<>}}>)[<<{[]()}(())>><[<(){}><<>{} +(<<[<(<{<({<[{(){}}{<><>}][<<>()>]>}<[<[()[]]<{}[]>>]<<({}[]]><[[][]]<[]()>>>>)>}><[((<[<<[]<>>>[[<>()][{}( +[((<[{[[([{[[<<>>{<>()}]<[[]{}]<[]<>>>]}<({(()<>))<<<>()><<>[]>>)<{<[]{}>((){})}[({}[]){()()}]> +<<{{({{([{{<<{{}{}}(<>{})><{()()}[{}<>]>><{<[]<>>[[]()]}[<<><>>({})]>}(((<<>{}><{}{}>)([<>{}][{}]))[{ diff --git a/2021/day10/day10_input_ez.txt b/2021/day10/day10_input_ez.txt new file mode 100644 index 0000000..b1518d9 --- /dev/null +++ b/2021/day10/day10_input_ez.txt @@ -0,0 +1,10 @@ +[({(<(())[]>[[{[]{<()<>> +[(()[<>])]({[<{<<[]>>( +{([(<{}[<>[]}>{[]{[(<()> +(((({<>}<{<{<>}{[]{[]{} +[[<[([]))<([[{}[[()]]] +[{[{({}]{}}([{[{{{}}([] +{<[[]]>}<{[{[{[]{()[[[] +[<(<(<(<{}))><([]([]() +<{([([[(<>()){}]>(<<{{ +<{([{{}}[<[[[<>{}]]]>[]] diff --git a/2021/day10/makefile b/2021/day10/makefile new file mode 100644 index 0000000..038dc5d --- /dev/null +++ b/2021/day10/makefile @@ -0,0 +1,2 @@ +all day10.cpp: + g++ -std=c++20 -o day10 day10.cpp -- cgit v1.2.3-54-g00ecf