From a83cef34f03bde09a604a60f4684e8cd2d6e1b5b Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Thu, 19 Dec 2024 15:59:57 +0100 Subject: [PATCH] y2024d19 --- y2024/resources/19_input.txt | 402 +++++++++++++++++++++++++++++++++++ y2024/src/bin/d19.rs | 27 +++ y2024/src/days/d19.rs | 96 +++++++++ y2024/src/days/mod.rs | 2 + 4 files changed, 527 insertions(+) create mode 100644 y2024/resources/19_input.txt create mode 100644 y2024/src/bin/d19.rs create mode 100644 y2024/src/days/d19.rs diff --git a/y2024/resources/19_input.txt b/y2024/resources/19_input.txt new file mode 100644 index 0000000..d5ed485 --- /dev/null +++ b/y2024/resources/19_input.txt @@ -0,0 +1,402 @@ +rbrr, gbgrgrg, rgurwgb, grb, ggg, grbugw, brwggrw, rbbrub, grguuu, uuub, uw, urug, bru, wwrrb, rbwbb, urw, uwuw, ubg, uugug, wbub, guubr, rru, gwb, wggrg, gubbwww, wrr, wbw, grug, brrr, rgw, urg, gugg, rugwuwb, rwu, rgu, bbu, ubb, gr, wwwggw, ub, uggrb, bbwrru, wuwrww, gbrbwru, uubu, bub, uguub, b, uwgu, brggrr, rruuggrr, buuu, brbgw, wbugb, rbwru, wrgu, bbg, uwbg, ruwg, bgugub, urwrrb, bggugw, bg, rgrrb, guwwu, gbbr, rwb, urrgu, brw, gbrwg, gbgwwrb, grgb, ggug, ugw, wbwwbug, wrbru, uwww, wwuw, wubg, burubw, gwr, wwubu, ubggrr, uru, www, wwr, uwbw, ww, rbbrwbr, rrwgru, gwuwgug, wubwww, gwbbwwb, bwu, ubr, rrguwr, bu, g, wrwbr, ggwb, wbr, uubwbrrg, gubrurwu, ugbg, wrurwbwr, buu, wuwbgrbw, ruw, wwgrw, bbbr, wbg, grrrrbu, wguuggwb, wrrwr, rbrru, bur, wurgwbgw, wgr, burggw, grugug, uugbrg, bgurgrr, urbw, gurur, wggb, rrub, uwgwg, grrug, uuu, gurg, ugugg, rurb, bbb, rrggwwb, brwbb, rrbub, ugb, wwbgg, gbguw, wgwgbb, wgw, brrw, ugbwrg, wgub, uub, bwgrugwb, guwgg, gurw, rrruwr, wgg, bgw, wrub, bubrw, uwrbb, uubugbwg, bwr, ugg, gwrbg, gbg, rbuwr, gububbu, bbw, wggw, rwrww, bbggbr, urgburg, rwbgr, rgr, wbugu, uug, uwg, ubgruurb, r, uu, rrw, uuwgu, gbu, urb, ugwg, bgrgrrg, rub, wubgwbg, brgubr, uuuburb, rbrwgr, wgwur, wbu, buurrgw, uwu, wbgb, rgru, wgggg, gubbr, uubwwg, uurbbggg, bgrwg, wggburr, ubwrg, wu, urbu, wbwrur, urgu, bggub, gbuwbb, uruu, gwwggwu, wugubrbr, bgrb, rgrbrb, guw, brr, rbguu, bgb, rug, gbur, gbb, rbrwbbb, ruuw, wrug, bbrwbgu, wwuwwbr, bgugur, rgg, brbw, wru, burrg, gu, ggwuww, wuw, uurg, wuwwbrwr, bbgbr, wb, ug, rrru, gwbg, ubwrug, rgur, rwg, ggrr, rgbub, uwubub, rwugg, wgbw, wburr, rgbu, ugr, ggwwb, gg, bbrbwgrw, gwu, brgwrwb, bguw, bbwwurr, ruu, ggbbu, ggr, bgwbgr, gru, gguuw, rbg, urbb, grw, wrwubbg, wbuu, ubwuw, gug, rbbr, wwb, buw, gw, buuw, wurgbuu, u, uuw, rwbw, wbbguw, bww, urguuwr, buwb, rugguggb, wwub, wrgubb, wrbr, gubbrw, guugr, ubbu, rwwbrb, bw, uwur, uugugw, bb, grr, wwuu, grrggg, rur, burugrr, ggb, rr, grg, brgw, wbwgu, uruwb, wuu, bwwgwrb, urgg, rrwuru, wurbur, uwb, bwrb, wur, ruwbwug, gb, bbr, uuwguu, ggwgwggw, bgurbb, wrw, rrbu, ubu, wbrgr, ruug, rbrg, rbr, bubwb, wbwgbwb, urugww, wrgbw, wgb, grub, gwrbuu, rbb, rrb, wbb, gguw, ggurrwg, bgwg, uuurw, wrwuww, brg, gbuub, uuur, rwrwu, wgu, rrrw, rbw, bwrbr, gwrgwu, ubbruu, rurrbrg, wwbwb, ubrg, wbbb, brb, rgwgr, gwg, brrgb, rwub, guwburb, buwgbru, ugbug, bwb, wgbwuu, wrbg, rrwugb, guuub, burw, brgwbwb, ubrub, ggbb, wggww, buwwwwuw, gur, ugu, guu, gwrbbrug, wbggu, gbgbuu, gbr, ggub, bbwg, ugwuur, grgr, ubguu, urgw, ru, bgg, wwu, buggg, gbuu, uuwu, rrww, ugrw, urr, rbu, bbugb, rgb, uwrbbu, wrwguu, rw, wwwu, gbbbuguw, wbrwwg, gbbrwrwr, wugw, rrbb, wurg, wgbubg, wug, wwwwg, br, rwbg, ur, rrrggg, gbw, ggu, bwrwb, rrr, rguuww, wuwbgww, bug, wgwru, wgbggw, uww, bwg, ggw, ubw, rrg, wg, uur, uwr, wrb, bwurbg, ugur, rb, gww, ubuu, burr, ggwg, rwr, gwuww, bgbwu, gub, bgu, wwgr, wwgb, bbrug + +wwugguwgrwwbrwubrwrwburubgrwubbbrugbggwrbwrwwrgggg +brwwgggrrubuwubbgbgruwgwguguwgwwugrgbwbgrbbwwuwwruug +gruurgurbugwgwbwuwubrggrgbgguurgrugbuubwgwrguwggwburrrgu +ugbrrgrwgbuggrrwuwwwbwugwwgbbrbuugbwbwbrrggwgruurrguuguw +grgggbwuuggwbbugrburbbbbbbbgwubbruuggubbgrggurg +wrggrurwbubuwwbrbrrurgrrrbuggwgbbgbbwgbwbbrgugruug +ugrrrrwggbbuuubrbggrgurggruurgrburbrgubrwrwgbwwwuugbwwuw +ggwrrwwrbbrrbwrgrwuurrbbwubgugruurbrggrrbr +rrurruguurburuwubwugurrrwgwgubbbwuurbggrwruuwg +gwbgrrggwbgbwrgwurbubgrwubwrgbugurbrbbrbrb +rwburrrbrwggbgwbruuwrwrrurwwuwwbugguwwrurwbwrrbu +uwruuuuwrwrwrrgurrubuwgwgrwbwuubgrwrbugubbbbuwbr +rwwggwwurwwrrrbwrwwwugbrggruwgruggwbwwgguuuuwurbrgbu +rwgbgwbgburuwubrbgrwrwubrrbrgubbwrgwbrbrugbbubbwurgu +ugbbbubgbbuwbwrwgbgbggurbggrwbgubbwuwbbrwgrubbg +wwbwbrggbrburubwgrwgbgrgwuruwrwwrgubwgurrbwrrwurwuurgggwgg +wuwgbwrbbgguwgwurgwbrgbwguwrbwuugubuubuuwgbwrr +ruuwuugwuuggbbwbuurguuwwgbwbgbgwbwwgwwuugugbbwwwruwuubrrgw +wwbgrburbbwurgruwugbrgggrgwwggbbgwgurbbgubugbgwubwg +wrggbbruuwrrbgrbwbuuubrruwgrwrrrgrwgwbbw +rgbugwrgwwurbgwubwruwwbrwggbwruubwbbrrwubrgwurrrrugbgg +buurwgrwgwbbugwgbuwbwurbwbggrugbbbwwbwrbwgrwurwubrgbrbbgu +rwwururugbgubrwubrrggbwwbgbrgrrbbuurbugwbgwuurgbuubrgu +bwgwruwwrbwgrgggrgwbruguwrubbrrgugbrbruwbug +bwwrurburbbwbuubrrwwuwubwrburrwuggrbbuwwggb +gbwuuuruuwguuwwbuwguuuuwgwuuugubbggrbuuuwb +uuwrwrwwbrubgbrrwbrbuuuwrrggbrrgwuugbuurrbbu +wubggwugrugbubgrbwwgbburbuuuwwbbwuuguggruugbuwwwbwrwbww +gggwbuwrugwruurgubrugrrrubbwwguwurbwbrgbwgwwgug +wrgguwwbbgbggubbuugbgrrbrurwuguwguuggwbwwrggww +ubrruwrbuuggwuuwbrwgbguurbwbbgrrwurbbbgrwbubgwubgbrwgbbrb +ugrgrwbrgwgwrrwbrwwugrruwrgrgwrurbbgurrbwwrruruwbbbrbrugu +wbrgrubuugggruwwrwbuwgwgurugurbbgwwuggbwgrugwubr +uugwugbububwrrgwwrrguruwwgwgbgugwgbrrwgrubbrwrrrbgwr +rgwuugbwbwurggurrbrbuwggwwbbgwrbbrugwbggwggwuurg +wgrrrurwgrgbwuwrggrbbgwgurugruwwugbuuruurub +buwgubbgbwwgbwwrrggwwrrbwgwwgrugbbguwwwwgbwuwuuuururgur +rburrbgwwwwgrrurbruwwbwbbwrwgubguwbbubwbgguruggruuugubbwu +grbgurbbgguubrrwbrwwgrwrwwubbubbbugwwgurwgwgrbwww +wrgbggrgrwggwuuwbrgwurgurrbwbbwrbgwuurwgrgw +gbwwubwgrwuguwggbgrgrwwgugbuuwbuuwruwwgbbb +ugrwwrrgwrguwgbbrbguugbbgbgbbbggbrubbbbrbguwwgu +guggrgugguuubwwgruwwuggbugwbwwwururgbwwwrggrgbugubgubg +rrgwrbggggbgwgggubrugrrbgrwwwuggbwwrgurwwuubgwrww +bgbuuwgwgrgwwggrggrbwurguuururwrbbwuuwbwgugbbgwr +bgbbrbgbrugrggrbwgurbgwwbbrurguwrbrwwwwwbbggrwbgrwwwbw +ruwbbgburgrbrbwrrbwwwuwggguruubbbrugbgbbrurbugrubgwgur +ubrgguggrwgrbrgrrbwrrrgrgbrruwgwrurugbgubb +wuggrwwgrgwwwbgwwuubrggwuuwbubgbrgbuwurubbwbuwwbw +grwbwruuggubgurrbrrwguggbwrubwwuuubbbgggwururw +guurbugubbwbgrruggubbgrurgggwugugrrubgbruububgubgubu +uubwwbgrurgrrurwbgwgwurguuuwguuwbwbuurbrgrgbuubgwbwbbgbbw +wrggguwwwwrgbbgrwrbwbgbbuguurrgbbubwbbwrbgwuwwruubrwrrgbgu +wgwugwwrrurbgwwrgbggbgbwgbbgrgrbuwgwrwrrurw +bbbwbbgwgurrgbuugwbbrubrgrrggurwgguwruwruggrwwrgrrgbugrub +bbwbrbrwrwbgurgrrwrrwbbrwrwgruugwbwrwurbwbwug +wwgwrrrgbbgguwguuggwbrruubgwrwuuuwrgbrburbu +urgwwgwbwbgrguwguubggwuwrbuugggbwuburubbuburrgbuwb +wrgbbwuruubwuuguubwuguwwgbuurgrgwguwbrbwwrgrggugbbbb +uuuubuuguubugbruwwwbrbrbgrrwwurwrruwwbuuwwrbbgrurbubbubrb +bgwurgbwrbwurgwbgwburgubuuubbbwbwwwuuwrgwugg +wrggwubugrugugubbguwgwbrwruurrggwuwwrbbgbbbrgbb +wruwwgbbrrgwrgrggbrugrwwwbrbwubuggugwbwuggbrwgburbwbbwubbg +ugwuuugbwwwrurrgubbbwguurbwgwbrgrwbwugugubbug +wrgrubuuwrgrbwbuuubgrbubbrbgrurbuuwggbgrwwgwwbwr +uururwwbrgwwrwggwbwrrrrgbbbuugbguwuwwggrgug +ugrwbwwrgbrbwwuuwuuurbgruwgrugbrrrbguuwubbub +wwwbrruggbuwwgbubwggrrgugruuurrurrwgwrguwwwrrgubugww +wrgrrgbrbggbwbubrwbrwrwbbgbwuwgbbwggwrrubgurbugguwuwuw +grrwbggrwbuugrggwubrbguuwrurbuuwbggbgugburbrrbuwwrrggggwwu +uubrruwgwuwbggbbuurwubwgburbuuwugbwuwurrwbrbgrbbr +rubuubuwuuburbbbwgbrrguwgrbbrwwgbugrubbruwgrgbgrbw +rwwwbwwguwrurbubwrurrbuurbwrubuwruggbguubgwrbugguuubrgrg +buwuwruubbrrrwbbuwbbugrwbguuwrubwrbwwrrgugwuur +wrrbuwuwwgwrgwgrruwrwbbwbwwruuwwuugbgrggubbbwwgb +guwbwrwuruwrgwuguguwbuwurruwbuggwuwrwwubugb +bgbuwwgrrwwuwrbgrgbwbrggubwwbggwwbbwwurgbuubrrwwrburwgrbb +wwwgbrbwrwrurrgrbgwbbgrbuwwbbugwwwuwwrurbu +wrgbrurguwgrruuggrrugurwuurrubuuguwgugurwgbrruburuu +wuwurubwugubrbrbwgrwbuugwbbbrwggrbwwguwwrbrbr +wrgwrggbwbwbwubrbgruurbbgggububbbgbburgurrgruwb +bggwbbrwbgugbgrwwgbbrruuguuuruuuwgrrrrgwbr +wrgwwrgrgbwugbgwgbgbbgrgbuwwwwuwwbubbbwg +gggbrrgwbwbuwbrbbbrbbwuubrrwuuggurwggwrwbwbu +rbugwwuwrbwbguwbgbgrwbwbbggwruwbuwrwwubrgbbrwurwwwb +bwwwbuggbuurbbuwrwwrbgubwbuurbrbubwgwgugrwuwgburwbbwwbrg +wrggrgwgbgrwubgbwgrugwbuggggurrrwbrgwwwgwwggwgu +ggburrrgubrrgwgwgbrwugwgwgrwbbbuguwbgbrwbuuurwrbr +urrgbwwuubwwubuurrbwwgubuuggrguwwwgbwwuguwgbugb +buugbwgwrurbbugbrugggwrbrwwruurgurwrburgrguur +bwugruuggubrbuuwurbbwbbruggrwwbrruugrwrguw +wrgwubgubbuwubwruuruuuwwrurrbgrrbruuurgrbrwugbbuggww +ugubburbrggubgrwgwguburwwburbubbrubrwrbuwb +wrgguwubbrrwbrwuwwbrwruubwgwwwrwwgbrrwguubbwwwugugwr +wgwuwwgrwrubrgwrgubrggggwuwrgrwwbwwbggrgbuwu +grwbwgubgwrggwrbgrwbuugrgrburbuubbgrwwwbwgb +bwwwbbrbwwurruuwwggrwbggrgguwrubbwbgbbgugubwbbuug +bbggwubbgwwrbburwwwgwrbwrbgrbubbwrrrgbgbruu +wrgwurrubgguggwgrrbugbbwbrbuurgbbrwrwrwgugwubbbubu +wrggggwrbbrugbrubguwuggubwggugrbuurwubgbuwubwgwgugugwubwbrwu +bwwugbwbgrrbgrrbbrbgggbwwwwggbbrbwwbbbuwgguugubrububgwwu +ugurgbgruurwbwgrruuwwbgbrrbbbggggurruruwrubbbuu +uwrugrrgrwbrgubrwwuwwgwgrbbgrbgbrwwuwubuwr +ggbgwbrwuwgruwrwgrrrrwugwgbrbbuwuwwbuubwgw +wrrrgguurbgubbgbguwruugwrbrgwbgwrrbbuwugbbrwgrbbugrgbbgwuu +urguruuggubbwurrubuurgbgbrbgugwwrrggwwwugugg +gugbggubuwubrgubwuwrwbgbrgbguggwrbrrgwguugu +buwurubbbwurgrubgwgggrruwrrbbrbugggggwbwwgwwb +wrwbbuburwrrwwururbrwgbbrbgwbbrrrbubbgrgbuggwrw +ugubruguuwrgwububrbgrbwgbwburwgurwbuwwubuwu +gwrgugrbgbubbwubgbrwbuwggugwurrburgwrwrugubwggwuu +rgbrgrbggwbwuubburrurggwggguurwuwwwrwuwurbrggrgbuwrgbgwbgb +wrggrwwbrrurbbuuwburubgruurbrgwrwgrrgrbguguuubwug +rguwwuuwgwwubwbggbugwgrrwgbrgbgurbwgrgugurrgguggrrbuuu +ruwubrwugurgrbruruggwbugbgrurwuuwbwrwugwgrr +wrgbrrbgubgbgwrbwgwubuggurguburgwrruruur +uburbrrbgbrrruwruwgwrrgrgurgrruugrruwuuugbuwburwubbrbbgw +wrbwuggbuuwwwuuwbwuuwgwbuubuwgrggrrbgbuwgubrruuggrrruuuwub +rwwgbrrurubuwrgwgrbgbrrbbbwbbbwrugwbubugwuwgwugwwurwgrbr +wrrgwrggrbuuruggggwrguwbwgrubgwbguuggbgrwrgubrurwuggrwgwrb +wwrggguurbuwbwurwwbbwwbrggwggbrbbrgugurbrbwwwrbrrggbbb +ubbrrbbwwrugugwrggwuwwuruwuwbwguwgggwwbwrbgbwuugruw +rggbrwgbbgwrwwrrbgwbuwwbrbrbururwgbugwwbrguuruwrbbbbwrwgu +rguwbuwgwrrbgwbwwwuwrrbrwwwburrbbwbruwggugubbu +rgwbgwwbugbgwruugwwrugwrrbuwgrbbwbuwubguubwbugugrwu +ubwwgrurugbrbrgwrbgrbwruwrbwwbugrwgwrwubrgbwwrurb +rurugbugrwuwbgrbwgbbrguwgbgugwgurbbrbuuurbwuuwwgbgg +rruubwwwuwrrwgwugwrbgwbuugbrbwugrwwuwurguw +wrgwwrgugrbrruurwuwgbwguwurrubwbbwurwwrgruwbgbwwrwu +bgruuwgwrgwugrrguwugwbrbgbbbgguurwrbubgwrr +gwrgrwurbruwgburrruuggbuwbgbwggwgurubwgurrbwuwb +bwbugugubgubrwubrbgruwrubbrurggbgrrgubrrbuurwrrubbwurbbb +bggwwgrbburbbubbuuburuguwubrubgbrubrrrgwwbgrrggrgggwrrgrg +rrrgbgwbgrwuwgubbwbwgubbrgwwbwburbwguuruwwwrbrb +wrgwbbugggruwgbwrggbbburbrgbwuuwurbugggbuggrwrbw +wgurbubuuwrwubrrgrrbrbwrwurwbrbgrggguggwubgrgbr +rubgwgbwbrubrbbrwwbbrrugrbbrrwuugggggwrwugbbbrb +wrwwubrbguubrggurwrburgggruwubggwgwbrgrggrggwuubwggubgggww +wrgwbgbrgugggburuguuwgrrrbrgrwbgubruwrwugbggubuwbbbbwwwbw +wrgrwggbwwrgbwubrubbwbbuuggrbbugrrrbguwbrub +grbrwgbugbgwgwbwubbuurgrgbbggwgbgbwwwrurguuubgbrwugb +urwbbbuggwugrgggurbuwgrrwwbuubwubugbgburgwgbubwuurwuwbuw +wwgubbuwubrgrgwguwbgrurbgwwuwbgwwgbuuuwwwwggwgrrwwwwrbrbuw +wurwrbgrubrrbguwwwgrggwwgrgbbbbuburgruwugwrbr +gbwgbrbrrrggrurrbrrwwrrbwwgubgwwuruwurgrrbbrwb +gubuwgggwgwwwwuwgggwgwwugrwbggbbwbwrrwugrwuurggwbgbgrwruug +uwrugrgbburwwbugrbwwwbbgurruwbburgrwwwgrwrwrggg +brbgrggwububuugrwgubwubbbwwgggrgurrwwggbburgbuugw +ggwwbgugwwggrrububbgrrrrwwbwwuuurbuuubbgwbwu +bgruubgwurbuwrrggugwwbwrbwbgwrwugugbrwwwbburugbbguur +bbbrggbgrrbrubugbrguwrrrruwbuwbgugwubgrugrwruugwgbuw +wuurgrrwurwggwwguguwwurwwugguuguubbuuruwubg +bbuuwrbwwwgggrgrrrrbgwwbwurrurubgubwburgbggrwrubgwbrw +rwuwwbrguggwuwrruwurubguubgwburrwgugrwubwwbwgwwbbbrgrbb +gguuggrrggbwbubgrbrrwbbubuwbrwrwgbuggbbbuuuuuwrgrrgw +bubbrwwgbwrwwggubgwwwubgbrwubuuruuwuwgwwgruggbw +wubburwgbbgruuubwggwurwrubwuwbrgbuuwbbguwwgrwbugbwrrgubrg +rbwrruguuuwwbrwwwbwrwrbubwuggwurrbugwubuggrbubwrubwbwu +uggubuwbuurrbgrugwwubwubrrburubbbgbugubrwwbuwrbu +ubbgbbgrbuguwwbgrwwwgwubuguubruugbguuuwbrrg +rugbbrguuruuruwgbuwrwbbubgrrbrwwbwugrwugbwuuwbwwbbwuwrg +gbubbuubburgrbbrgubggrbbwwuwwbbrurguubgwubbubbbuu +uggwrwuubrrwrrwurbrwrguurrugwwgruwrgwrrrbbuubgrruruwr +wrgrwburgbugwgruburwguurbgggbgubrurwurguwwurwwrbrubbwbwr +bbrubwwbubwuwgwgbrbwuurwrrbgguwbwbgbwuwurbbwbrgrrgwbbgw +bwurwgwgguubrgwbguugrubbrgwrugubbgwwubruguwbrbwb +wrgrwggurrrgwwggbgwrgrrubuubwbwrrrwggbbgbgrbwgwbgb +wubrrwbbugrrrrbbgrbwuwwggggrrbbbwurrbuurwbuwrwgrbggu +gwgurwruwwbbgbrurrrbrurrrgrrggbgubwbggugrwrrbuw +wrgwwwurubgbrgwbuguubwuwurbuurwrruuggrwrrburuuur +gubwbwuggbbguwwbgbgrgggbwggbrrrrwubwrrrruuwbgrrwguww +wrgguwubgwwwrwwbrbgrruwbrurrrugwrrbbrgbgbw +guwwwgrrurrwuwbwrgububgwurrbrrbgbrrwguwrrggguuugbrbbwrgw +rwwbggrrugburbbrbguwbgwwrubwrrwwbbgurruurbggruubrgggg +uwbgbugwrguuwurgrrgrbrwwubrrbuuwggwwwurgurgwrgrwbr +wwgrggwgwbgrugwrggbbruurbgbbwrgruuwbbrurwb +urbwbgwbbugbuwwrgwwwwgbbwbruwbwgwwrrrrbubrbbgurbgwuru +wgrgrrwububgruwubgwuuwbubbgurruruwrubgrgwg +wbbbgbbbguuuubruurugwbruwbbrbwubrgrburrrrwrrb +wrggrugrubgrwrwgugugrrgguuwrubwwugrrbuwbw +uwbbggrrburubbgwwrwgggwgwggwgbuwbwgburbgrrwr +wubbgrggwrrbrbrgwrbubbruugbrwbbbugbrgguubgrgwggu +ruuuuurgrrrrrugbbrgburubbwuugwwgbgubgubwubguuururgrwb +bwgrugbbwbbrrwuuuruwubgwuwbrwurrrbwgurwbur +ubgwubrburgrgrwwrrurrgguwbbwbrbwbuuuuwwwugbrwgrwguubwbrrrg +wbrbwruwbbubbgbbgurbuurbwrggbwbgrugugwwgwwwbrburbgbbwr +ubgbbbbgwrwgrgrguubrrgugbgugubrwbruguwbwrugwuburwwbb +ubrwbuubwuubrrbbrurgbwubuwwbrbrruwwrgrguwrrbwgrugwbubw +gwwruuuwurbwrwrubrwwrrbwrrggrburbgwgruwubrrwgubbbuw +rwggugubbwgwrwbwrwrwrgwgugugguruwgwbbrwbwrggwurb +ugubuwurgrrgugbugrrwrguwwrrurubrbrbrurbrbbwbbuuwugrg +uuurwubugubbggwwwurbwgrgruubrwbwgguwrwwrbubbgrgrbbgubb +wggruwbwbrwgrwrwbrbuwbrbbwrwwrbubwggrbuwuggbbrgwrgbggwwb +wrgbgrbrgwbggbgbrwgrbbwgrgbgrubbwgbrwrwwgbbbwurgwbgwbwbrug +urgwwbwbbrwugruuruuubgbwubgwbuwbbggwrbrggwurgrrrgbububwg +wguubbbbgwuuuwrrguurgugrrubrguurwggburbgrwbgwuu +uurrbwuwwuwugbgrbgwbggwbwgwbwugbbwgurubwgrrbb +wrwrbuggbbrrwrgugrububuwggbwrbrrbbruuuggwb +wgwwurrwuuuubuuggrgwwuurrugruwbuwgwrrrwrwbwrubugrwwuwurbgw +wrgruubububrbwggggbbrrgrbuuuuwrgwggruwurgggwgwggwuwwwgrwgb +ruuggwgbrwwbubuggwwugrrubuwurbgrugrwgwubgbggrbbgbwgrurwggg +bggbrgwrwruuuuuwbbrgbrgwubbubugbguugggwwrrugrbu +wuuwguubwwguubbwggwwwurbgbugbwwwugwwguuugrwgrwrbwbrbubbgbg +ggrgwbwrubrwugwrgbrwurwggrguurgurwrwrrgubbbwrwg +wrgguwwrbubgrurgwbbuwguwuwgwbwugruruwwuuuwrbrubwrgr +bgwrrbwugrbuggrwbuwrrbrrggggruuugbrrguwubur +wrgwbgwruwggbwuubrugbgrrwubrgbburwwrbrwrwwrbguwgur +buwbrgrbubgubgugwrrbwbgguuwbbwuubrgrrwwgubbbgwgggugbru +gurbrrwbbwgubrrwbwuubbuuruubbruwrwwwrrbrwrwwbrbrubb +wrgbbwbrrwwrrwggbbwrrurgurbgwgguggubwbbbruurwrwuggg +wrggrugrrwwbgwwwwbugbbbbrwwgggrgggwbuguurgu +wwugrwwbbggrgwurgrrbbuwgwgurrrbgruwrwugwrr +bwrwubrgugguububbuggubbgggugrwuburuwrwrrrgbrwbrgr +grgggugwbuburgbggguubwbrrgrguuwwbrgggwwwrgbgugw +ubgbbugugbrugrwuguugwbggugbbwrgrbuurwbgrbrbgubbgwuwuwgbgw +gurbubbwgwuwwgwbrbuwugguggbgrwgggrwuwwbgbgwbg +rbuuugbburuuubgrubrbbrwgggwbbuugrugrrbbwggwr +wrgrwrwbwggwrwuguwrurbugwbruwbggbggrrwurruwuuruwru +uwguwwgbgggrubggwugwbwrbrbbwbgguuwrbgggwugrbwuwrwwgrur +rgrwrgwuwbbbrgwrrwuubgrgbwwrrgburbgbbubbgubwrburbbwuuur +wgruurgwubgubgbwbwbgggurbgbrggrbbgwgrrwggrwwgg +wgwbwuwwwgwrbubwbuuuwwuuuuubuwbuurrgbgbubbbuuguburwbgru +wrgbuurwbwbwguwrrugbrrwuuububbrgwbgugubbwgugrwgwwggwuwgrgrr +guggbbgugbwgurrwbuwruggbbubbwguuuruuwwggwrbbgruburgrrbug +wrgwuggurgbwgrgrggwwwgbbrwwgguwgguggbbgbbugwbrruwubrrrbrwuu +bwgbuubgrwbugwbrwuugurwgbrggbgrwrggwbrgguwbr +rbwwgrbgwwuwbrwgurbguwwgwrgwburwbbbwgrrgubugwurrggrwuww +ggrwruugwguuwrbgbrgbrggrwugwggbrgwgurbwgbbrbgwubuggbbrgugw +uuwwrwrrurgbrwrgbbuguruwwuwrwrugwrgrrbburgu +grbbgurubwbwbgrwwgruurwbbuubrwwrrbwubwuwbbbrwu +brrwwbbuwbwrbbgrbgbbuwwbbwrwwgubuwruwbgbwrwwwggug +wrwbgbgggruurugwbrwwgbuguuwguurbgrgrguuwwwrgu +wbwgbubrgbuwwwwbwbuuggugggggrwbwrwgrgguwrggrbwrgrburwbubb +ubgwwrbbwbuwrguwrrwrrwggruwbgbrwuwbubububuggbggbrwbu +urrbwuwwwrugbugwwgwbbubgrgbburuuwgbgguguugb +uwbugbgubgrwgbruubbrrbrwgwuubuwbwbbuwrgbwugbr +wrgwrrrbugbgwuwbwrubwgbbbuguwrrgrrwgbbgurwwbrbbggggrrbrruwu +rwrrwbwwggubbguuubrwrurgrbwurguuuruuwgubwgbwbrbbgbgb +grrbrgwrwbwbbgguwgguugrwurrbwwgwgbuubgrbuwbbbgbbbuw +rgwubwwubrrgbrwwubuguugwbbwuwgbgubgruuruubgurrgwguuggwrw +ruwuwuwbuwrgggwgrruguwwbrbuwwgugbuuwruwbwrbgwubwu +ubgrgrguguwwbwrwwbgwurwurrrbggrrggubgrrbuuggbgg +wrggwgrbugwwgruwwubrubgrgggwgubbbwwwwrwurubrwrggrwwbrgwgw +gwbggrggwbgwgbrwwuuuwbbwrwgbguwruguuugwrbgrbbrrwrurrggbb +brrbuwguwgrbbburrubrbwburbrwbgwbbwgrrgwugrg +wgruguruwwgbrurbugrrrwrgwbrwuuruurrwrrgwuuwgwg +buuwrbwbubggrwugwwbuwgubbbrbbgbubrrwrbbwwrrrrrwgugurrrbbb +rbrrburuubrwurwgguggggubgbbruwwggburwwbwrb +ubgruruwbrgbrbugrbburuwugrurugrwbwwguwuuwuwgubgbrgwrbbggbg +gguuuwwrgggwgurrrubggubruubbugbbuuwgrruuwguguu +uwbwggbrbrrbuggbwwwubwwuuggwrwwrurrwbgbwuwgw +rwwwbuurburrrwubguwgrguguubrbgwbggbwurgwug +gbgugwbuuwuwguwugwruwwbwurguubuurbbgggbgggrrwgwbgu +gbrrbwwbuugurwbgrrwwwwgruurgbbgwwwgrguuuwgbgbgwwrbgwr +gbwubwugbgwwugwgguruwubwggwuruwrbbwwbggggrgurwg +wrgwbggbrgbuwrgrggwrwbbwwuwruuwuwrgrwwuwg +wbrwgrgbrrrwuuuuuugwwrwbrbwbuubgggrrrbwuwruggwbwwubwbrgbwb +uurbbgrrwrbwubwwwgbrrrrugbrbrbgbubrgrwbruuwggbbwbrg +wrgbrrugrwrugbbrbwgrwbubruuguggwuwugrgbruurbbuubwbwur +ggrwgwgwugbggwrbwbrwwrrrbgwrbwuwgwbuuurbwwuwbgubuurwb +wrgrrbuwgurbgubwwwwguuwggwbrbwbwwwwuuwggb +bbrurwwuwbgggrbgwrbrbgwurrrbbggrguwuwgggbbuuwggruwwgbw +ugggggbwgrwubrrwurwgrwwurwrrgbrurbuguwbgwwrrbgwwwwrgwrrw +rurbgbbwgrrgwuuwugwgbubwrwruugubgruwbwwrrg +wrgrrwggbwruuugrwurbuwwgrgururgugwuwubbgbbgrwururwrgr +wgrrbwrwrrbgwgwwrwubgrrurbgrwruguurrruwbwbrwugwr +gbrwwbbbuwbwwuwubwggwrrbubuwrrwbrrrbuwbbbbugwbgu +gurwruwurbgrurgbuwwgrrrwrbrrgwrbggwwrwruggurg +bgururwbrguubbwbwbubbbrrbrbwrbgrubgwbruwbbwwruurruurrgurru +bgugrwbbbgrbwuwrbubwbwubggwrwrwgrrbrubggwgwruwwuwwgrbwwb +rbguwuwrrbwbbgrrururugbwwruwwrrwbugwguggubruuuuburrguugbu +gurbggwbggwwurggbrgbgugrbgubrgrwrrgwguubwrurrrgrbwwbugwrw +wrgbuwbugrgwrugguggbrrrgurruuuwgbguwgburb +gurburbuuubuwrbwrubwuugwgwbuurrbwuurbrruuburwggw +wgguwuuwguubuwrbwwwbbguwuugwrbubwugugrwwgwwwwggurwrbru +wggbwgwwrggruuwbrubrrgbggrgwrwrgubbwuugwwuwrggrg +bbwbgggubbwwuwrbggwbrgguugbuuwubguuwwrgbwuruwgruwr +wuububrwurrgwubbgrbrrgubbbubgwbrbwrwrbwurwgg +bgbbrbwwgubwbwbgggrwbrgbbuurgwbrrwgwgruwwrguuggubrbrurwr +rbuuwrwbuubwrwrgrggurgwrurrgubbuwuugwbgwrrw +wrggbwurgrrubgbgwrrgbruuuuwrruruubbbgrgubbggrwbbuugg +buggwggrgbwbgwwbguwuwrbgwrbbwwrguwwuwggurbwgurbggubrrwgg +guuggrbbuwbrwgrurrwwwuugwbwugbuwrbgrwguuwbgubgrbbg +uuwwwbgugguuwuggrburwwubgurwwbuugrrwgugwuu +buurwugwrrrgggubgwwwggwwgwugurbgrgwwuuubwuggurwrrbggbguwgr +uuwwbgggubuubgurgwurbwguwrrwgwugubruuugwuguuuwwwgwgb +rwbgrbwrwugbbwgwrwrgubbbbwwrrguwwubbugrbbwgbg +ugrurggwgbgwgwrruugrwugwrgggbuurwbbubuugrbgbru +uuugugurgbwwwwrbrgbrbggrbrurrgbbbrubburbbbbrrrbbbgww +brbburruuwuwwbgwugrrrrggbwgrbrgwugrwbwggrr +rbbbgburbwbwgbubbrugbgwgugwgrbubggwgwwuwbuurbuurgwrugrrg +wuuuubrgwrwwwwugugrgwbrubbbbbgwbbgbubrrbbwgwwrgg +ubrwubuurrrwugruubggwuwbbbuuwgbuubwrrrwbrwwwwbubwgwbrwwu +brrurgrwwrruwrrubbwuwguuuggurbwgruuurbggggguwurrg +uuggbrwgbugguwbgrrwgwwuuwuururwwbgbgrbgbuu +grbbbrrgwrurugbwugbwgrgbgbgubugbrurruubgrugguubrwwugwuu +ruwbwbugbbbgggbrugrgbbwbbgrguwrwuurrrbugbugbwwgbbugb +ruwwrrwugwwbubggrubwbbgwrbgwggbwgguuubgbgubg +uuwwugrbbwbbbbwwwwgrbbggurubwrrbbuuubrrggbgb +wrgrgwuruwwugubrbrruggwrbbgrrubbggrbrwbruwubgbbrrwwgrgbgubgg +urwuuwgugwwubuwrgwbwbgbbrwrwrrrrrbuburwbrurwuuruuugbrbb +ggrurrwubwuwbugguuruuwggwwrgrgwwbbrwubgrbggbbur +rwuggbgubrwuuwrwrbbbgbrgwwuwrbbuwrubguuugbbgwww +wbrwgbrubgrrwbrwrwrwwrgrrbbrwggwbrguwwbrbbwggubbrruuwgrb +bruwgrwrrgwrbugruuubwbruuurgbwgguwwruuurwbgr +wubrurubrubrrwbuurgrgubgwbgrrurugguggbrguurbugr +gbrggggugguugrrrwrgrrurggwwrgubuubwurugrbbrrrgg +gwrbugwubbuuwrggubrrubbgggggbgbggwrbrgrwgwruwbwggubug +gwrrgubggrurrgbbugruwgbwbrrbwuwuwbggwgrrrwgrggubbgurbg +wrggwgwgwuwbrwwbwwgrurubugubgrgubuubbgwgbggwwwg +wwrwbbrwwrwubwwwgbwrgguwuwrguwwggurgwgbburuuwwgwrggg +wwrbwwbbgbgbuwbwuggrbrggurbugbrwuwugrrurwbruw +wrbgrrggbwwgwwwgbwgbbrurwugwgugurguwbrgubr +gwrbgbgugubgbgrugbrbgrgguwggwgubugwurwbwrgwbrugwwwb +wbgugubwwwrurggwuwuwrrwwrwgbbbuwbbbrgrrgwurw +uuuguubwbbwwgbbwwggguubgububgrguguubwwuugwwrwbr +rwbgrwwgwrrruwugruuubbwrbrgubgrgwgbbbwwgburbubgrg +wgbuugbgwbgwuwwgbwgwwguwrbuwurbuwrbwwrbbrwrrrubwrgbbug +ubuwggbwubbgrwbbbwwrrbuwwuwwwwbbubbwrwbubwgrr +uurwrurwrbbbgwrbggbwwruguwbwgwururgugrugruggggbgwwrrurggg +wrggurbbwgrurggubgbggbrbgbgrwbgwrwbububgrwrwgrwwubuububu +wrbwrgggggbuwubugurguuuugbwuwuuruburgwrwuwr +bggbgwgrrrbwbwurgwwrggbwrwgbwuwwugwbwgbrrrbgrwwgwrwgbr +ubuguruwbrrrgbwwgrgggrruwgggrgrbgrgwubggbrbuubw +grurrbguuubuggbbguurbwwbrrurguwurubrbgwggrguwbrrgburruugb +wrgbgrugrwwgwbgubbwbbrwubruggruuguuwubwgwurubggrbgwurrrrr +wrgrwuguggwwurbwubgwrbrugbruruwuurgurbbgrgr +wbbrguggbrbgwgwrugbuwrgbrgbuurrggggbrwgwwwuubbub +grrgwbwwbruugggburwbwgrbrggwgwwwwuwwbrwrbwr +guuwuuuwrgwwgbruugwwwrwuggrrgwbwwruuuuubububrwrbgurbw +rrwrrurggwurggguurrrrurwugwwrruwrruubwrbbguubww +grrwgrrrwbubggrrwbbgggbgwbbwubrbwwugugggwbg +wrgrrggwurbwbrguwrurwbwrbrbrggggrguwbwgwgwrbggbgrbgrb +bwrbwbwurbrugggwbgbrguwrugugrruubrggbwuurrubub +wbgwwubuurwwubbwwgurgugbbbgrgwuwbbwrbgwbwguugurubr +bbbbruwuwgwbuuugrrbgugrwgrrwwggugrggugbbgrrbw +wrggrwwubwruwbugubgurrwrbrrwbgrgbgrruguuubgbbwuwbub +wgurrgubgrgbgggurgubbugbbbruruggrbggrgrwwrw +rurbwwuuugurguwgwguwurrruubuguwwrbbburrbrwwugrruuw +wwubwbggrurbwubbrwbuuruwbgugbwgwgrugubbwbub +ruwbrbuguwuuuwwbrbwguuwgrwuruugbrgbbwugubrrrgrgb +rwrbrwrbwuwbuubrugwrubwbuuwbubrwbrgurgwgbgrurwrruuwu +rugwbruruguuuwgrbwruggggwbgruwrwuggubgruurbubwug +wgruguuruwbrrbwubuwgbrwugrgubgrwgggbwwuggbwbb +gubuwrgurwrbrbrugrruuwgbbwubwwbgbgguwuuwwgrbrwuwr +grrrgwguwrgbrbbwbbrwbgugwbrgggggbbrrurbbgbggwbuugwugb +gbrbggrbgrrbbggggubbbwuugubgggbgbrurburugwwwurwwuuw +wrgguubrrwbrrugwuuruurwbuuwgwbuugubgbrbbrrbgrbgwrrrwrgguww +uwwburbrrururbrwgrwrgrbuwubgugwwwgwgwrrurggu +rgubgrwgruwwwgrrruwrububgrrwuubbwrguuwwrrubururguwgbrg +gguwbrrrrgwbbgrrbubugrgwwbbgwrgrguwuwwrwbwwgubbgubbuwuwgw +rwgrwrbuwbwrrwrrbrrbbbuubgrgbrgugbuuuwbuuw +rgguwggrbrurwrrgbruwbguwwwrubwurbrbrwwbwwggrrrwbwg +rwruubwuwguwrurrubwuubbburwubbwwguguurggbbwuwb +wgwubbbrrbgbwrgubrgguurrrbuurwubbbguubguuuurguwwr +grwwbgggrbbrbwgrwbuuuruwwgbbuguurgburbrgugurwb +rgugwuuubgubwwwwbbuurwwwburrrgurbwbgbuwwruuugu +gurrwwgrgwrbrbbgurbwrrbubrbuwbuurrrguugggrrbwugbb +wgwburbwwbubrgurgbbugwrbbrwggwgbwbrbgwburbbugbrrbggbwwwwg +uwubgbbubwrbbbubgbbgwbuguububruubbbwuwrububbg +ubgbbuwgwrbrggrbrwrgubbubrbbuurrgwbrggbuuwwwrgwubwrbbwb +wgrbrwwwgrbgruwbbwgbggwuugggwggbrwrwbburgubgburrwrrwrwbw +wrgrbgrbugubrwwwwuubbrbrbrwgwuwbbrgwrbwwrbwbrrubbrr +wrgbburuubwbrrggwurbwwbrwuwwugrwrbwwbwgrwwwrbrurubrgrbw +rwwbwgwbgggwuuwwbrwgwgrubwwwrrbgruubwrgguwrwr +rurbrwwruuuuugwgbbwgwrgrbbwbrwwruuuwwgrbgwbbbuurururwww +uwguwbuggubwuubururgbgurrbbugbwuwrgwwrbwwuuwruwuubgb +rwubrrrubgwubbgbubrrrrwbbbgbgrbbbuuwrwuggwgugr +buwrgbggrburwwrrwrrgbrwbwurwgwubgwbwgrrgwbwrrbrbrgrbgububb +wuuurwgbuwwwwuwbbugbrwurrgguwbbbbuuggwbrrwbgrbrgwrgrubug +bbuwbrubrwbgurwbwbguugwwgwrwbgbwruurwuwbuuruuggr +rbbrwwbbwuuwwuuurburrrgwgrwbbrrbuggwrwrgruugbu +gbrgubuurgbgguwwwwubbgrbwrrurburugbwgbubbwruuuuruuwbbgwguw +wurwggrggwwrwugbwgrwuuwrugbuuggbgrwrgwggrgugrgrwrrwbb +rgwrwuwuwrgubuwbgurwrgurwuuuwgwwrgwgrgruwuwwggwurwrbbuw +wrwwrgwbwgbugggrguuurwwuwrbrwrrruwwbrrrgrruubg +wbwrrruuurgrrrwrbuwbggbguwugrbwbggbuburgruwgbbruubrwbrgrur +uuubuguurruuwwurbuwbgwrrrbrbwrwbuwubugrrruwuggrrwb +rrbggbubgrruubbgubuwubbgwuubgbrruwuugggbrbuubgugg +buwugbwbbrugbwbgwurguwbwwbbgbbbuguwgrwburrgggbgbguruww +wrgbgwurgrbrggrburguuubugbwgugrwbwwwwbbuubw +gwruuubuubbbwurbgurrrbwwbburguugbwbrrgbubrwwrrwwgbbgbu +wgubuugggrugrwrrggugguwgbwwwruuuwwurwbwgwbbwgr +buwwwgrruuuwrwgggbbggbguuwwugwwguuuuuruubrruubbuwubggbgwrg +gwrgbgubrwuruwuruguubbuwrbggwwrguugrrgwwbbwgwrbbwbgguuw +wrgrbwuburwgwggggrrbrgrbbguuwuwbgrbwbubbbbb +wuuurbguuwrurgggrwbgwrbgggrgrggrwuwguwrrugugrugwbuwbrug +ugbubbugwbwgugbwuurwbuugbgwbgwgbrurgruuruubgugbwugwubu +rgguwubwruubugbrrguruugrrwbrgggurrgbugwbrggu +ggwrgrrrrwrggbbwwuwgbrrrugrrubwwwrgrruugurwgrbgwbg +gugwrgwbugugrruubbbgugrwuurbruubwrrbbuuubbb +gbuuggruguburwbrrbrggrguwguubugbwggbgwuwrwgrgub +urbwrguguuwrugrbwgrrgbwrwrwwuuwgbgwbururggwurgrw +wuwurrubrwubugbgwgwwuguugbgbuwrwbuwrgbggrurgruwuwuuu +grrugwbrrbbwbrgguuwbubbgrugrwbwrurwggbwwwr +rwbggurbrwubrbgwuwruwbrgwwgrubuuuurbbggbwrrrwur +wwbugrgrgruwrgbugrwrgwgrbruuuuubbubrwbwrgrb +wbbbrgwwrrrwwbrrwwwuwugwbrwgrbwuwuggbuwruuugubgbg +wrgbuggbbrbrubgubbbuwrubbuwwgbggbbwgrwrruwgguwguwruubw +guggwbwbgrrubbrwrrwgugguuuwrgbwgbbguwbbubw diff --git a/y2024/src/bin/d19.rs b/y2024/src/bin/d19.rs new file mode 100644 index 0000000..a89dd98 --- /dev/null +++ b/y2024/src/bin/d19.rs @@ -0,0 +1,27 @@ +use std::{fs, time::Instant}; + +use utils::time::get_elapsed_string; +use y2024::days::d19; + +fn main() { + let now = Instant::now(); + println!("Part 1:"); + part1(); + println!("Ran in {}", get_elapsed_string(now.elapsed())); + let now = Instant::now(); + println!("Part 2:"); + part2(); + println!("Ran in {}", get_elapsed_string(now.elapsed())); +} + +fn part1() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/19_input.txt")).unwrap(); + println!("{}", d19::process_part1(&content)); +} + +fn part2() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/19_input.txt")).unwrap(); + println!("{}", d19::process_part2(&content)); +} diff --git a/y2024/src/days/d19.rs b/y2024/src/days/d19.rs new file mode 100644 index 0000000..fb64b12 --- /dev/null +++ b/y2024/src/days/d19.rs @@ -0,0 +1,96 @@ +use std::collections::HashMap; + +use itertools::Itertools; + +pub fn process_part1(input: &str) -> u64 { + let (patterns, designs) = input.split_once("\n\n").unwrap(); + let patterns = patterns.split(", ").collect_vec(); + designs + .lines() + .map(|design| { + if possible_design(design, &patterns) { + 1 + } else { + 0 + } + }) + .sum() +} + +fn possible_design(design: &str, patterns: &[&str]) -> bool { + for pattern in patterns { + if design.starts_with(pattern) && design.len() == pattern.len() { + return true; + } else if design.starts_with(pattern) { + if let Some(stripped) = design.strip_prefix(pattern) { + if possible_design(stripped, patterns) { + return true; + } + } + } + } + false +} + +fn possible_designs(design: &str, patterns: &[&str], memo: &mut HashMap) -> u64 { + if design.is_empty() { + return 0; + } + let mut num_possible_designs = 0; + if let Some(count) = memo.get(design) { + return *count; + } + for pattern in patterns { + if design == *pattern { + memo.insert(design.to_string(), 1); + num_possible_designs += 1; + } + if design.starts_with(pattern) { + if let Some(stripped) = design.strip_prefix(pattern) { + let for_stripped = possible_designs(stripped, patterns, memo); + memo.entry(stripped.to_string()).or_insert(for_stripped); + num_possible_designs += for_stripped; + } + } + } + memo.insert(design.to_string(), num_possible_designs); + num_possible_designs +} + +pub fn process_part2(input: &str) -> u64 { + let (patterns, designs) = input.split_once("\n\n").unwrap(); + let patterns = patterns.split(", ").collect_vec(); + let mut memo = HashMap::new(); + designs + .lines() + .map(|design| possible_designs(design, &patterns, &mut memo)) + .sum() +} + +#[cfg(test)] +mod tests { + use super::*; + + const INPUT: &str = "r, wr, b, g, bwu, rb, gb, br + +brwrr +bggr +gbbr +rrbgbr +ubwu +bwurrg +brgr +bbrgwb"; + + #[test] + fn part1() { + let result = process_part1(INPUT); + assert_eq!(result, 6); + } + + #[test] + fn part2() { + let result = process_part2(INPUT); + assert_eq!(result, 16); + } +} diff --git a/y2024/src/days/mod.rs b/y2024/src/days/mod.rs index b6ca235..194064b 100644 --- a/y2024/src/days/mod.rs +++ b/y2024/src/days/mod.rs @@ -25,3 +25,5 @@ pub mod d16; pub mod d17; pub mod d18; + +pub mod d19;