From c144c876a2428ff3ff082eaab7c6a60a36d1e1a2 Mon Sep 17 00:00:00 2001 From: Andrej Orsula Date: Mon, 23 Dec 2024 16:36:09 +0100 Subject: [PATCH] aoc2024/day23: Add solution Signed-off-by: Andrej Orsula --- README.md | 4 +- aoc2024/input/2024/day23.txt | 3380 ++++++++++++++++++++++++++++++++++ aoc2024/src/day23.rs | 174 ++ aoc2024/src/lib.rs | 2 +- 4 files changed, 3557 insertions(+), 3 deletions(-) create mode 100644 aoc2024/input/2024/day23.txt create mode 100644 aoc2024/src/day23.rs diff --git a/README.md b/README.md index d599fb2..970437a 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ My solutions to [Advent of Code](https://adventofcode.com) puzzles. | 20 | [Race Condition](https://adventofcode.com/2024/day/20) | [day20.rs](aoc2024/src/day20.rs) | 335.5 µs | 17.31 ms | | 21 | [Keypad Conundrum](https://adventofcode.com/2024/day/21) | [day21.rs](aoc2024/src/day21.rs) | 529 ns | 476 ns | | 22 | [Monkey Market](https://adventofcode.com/2024/day/22) | [day22.rs](aoc2024/src/day22.rs) | 7.427 ms | 13.17 ms | +| 23 | [LAN Party](https://adventofcode.com/2024/day/24) | [day24.rs](aoc2024/src/day24.rs) | 326.8 µs | 147.2 µs | - - + diff --git a/aoc2024/input/2024/day23.txt b/aoc2024/input/2024/day23.txt new file mode 100644 index 0000000..58f2693 --- /dev/null +++ b/aoc2024/input/2024/day23.txt @@ -0,0 +1,3380 @@ +qs-sa +sj-su +pg-tn +un-wz +qf-oe +rp-km +kx-fp +ch-fm +hl-uk +jd-pa +cv-kp +ng-az +uo-tt +sk-gq +ca-lw +dz-bi +dg-bg +du-bs +hn-ok +pm-ed +cj-zd +oe-ec +zz-ja +gw-dv +hm-mv +ii-ij +ea-ya +hj-pb +jh-cu +wj-be +gt-qz +fn-id +zv-du +qw-hw +di-nq +jf-dv +qw-fx +cr-jl +qi-dm +vm-gr +dp-sp +sp-re +iy-vp +oc-vb +yr-hk +yo-gh +nc-ey +rc-bw +zf-cz +qj-qm +np-sj +nr-ti +xa-ni +zm-bk +wv-ni +he-zb +kx-yn +cm-yo +fw-wo +vv-na +vl-ru +cg-aa +gm-kz +ed-dp +bt-vm +qf-ud +nj-vg +jw-tl +bf-vg +kk-fc +gk-jo +hy-ot +ep-iw +gd-ym +de-sz +ni-zv +eq-ln +bm-qv +eu-ed +hm-rk +bw-ct +vv-kr +gm-oz +uk-ew +wf-gx +wc-ox +tk-uj +za-zr +ta-xp +yi-jl +gy-nx +by-pd +gm-yb +nr-di +dp-eu +tt-df +mb-ty +af-ee +lz-ex +mp-ef +ig-vf +sv-ic +gb-tb +pq-bw +ud-tr +oz-ft +mq-zz +oy-pw +kk-yz +at-zm +ml-fu +wj-cc +vk-ck +xd-fe +lk-xo +dt-ii +ym-hl +cc-bm +np-tc +za-vm +gh-sv +xo-dg +wc-jk +bk-re +qx-cx +fj-xf +ol-zh +fo-zy +du-yy +jq-pa +bz-dz +sh-go +pi-fn +ax-cy +db-ec +ms-kr +bx-qj +oh-en +wy-ip +ac-px +yh-tv +fc-nj +om-jw +dg-nk +ld-pm +nw-hu +yt-ss +me-ov +mt-lm +ja-pf +pu-ed +px-lh +iz-wu +hh-qi +ll-kz +yp-ta +ft-nq +ud-de +xs-bd +tw-pt +hi-fp +qq-be +ta-ey +gv-sy +tq-ca +sr-kc +ih-at +ch-ts +pv-qw +xm-ey +mp-ds +al-jy +zg-xa +gf-np +lw-ne +ub-wc +oy-kl +tp-wv +qm-cz +nq-xq +lk-qy +wb-ll +ts-hu +nd-vm +ja-dz +eg-lv +zx-rh +kt-gi +uc-aa +nr-ny +tj-mq +ll-dk +sj-az +qj-ak +in-fo +uw-zx +ld-ml +lt-jb +ot-uj +nd-xi +ja-jp +lh-jw +fj-pk +xz-tb +nd-vn +xg-lc +et-gi +ap-gs +ud-ec +rf-ik +ko-nu +ll-ra +te-uu +uu-ti +av-sx +su-fv +lg-dr +gb-bj +uk-bk +mt-ya +jw-od +kz-vh +to-yq +jg-jd +sr-ks +fc-oc +yk-ae +dh-yn +nt-nz +gd-gu +tp-dr +rc-rz +ws-bc +sv-gb +wb-dk +kf-uw +bm-cz +yp-uf +or-sp +mt-ea +to-hh +dc-bz +bi-pf +ve-xo +jv-qf +fd-al +sk-fx +fu-do +xk-yy +qs-vp +cb-ha +bw-lq +ln-wo +my-os +ce-xp +an-gu +jv-ti +pj-zm +av-fe +hn-ue +pn-el +fu-fh +da-ut +jd-bu +yy-go +yi-qd +zw-uf +jb-xm +ps-lw +dh-kx +zi-pu +fh-ph +kg-ee +wy-za +rb-jv +xj-rz +uj-vp +df-lh +yz-qh +ra-pi +aw-zv +oq-fg +hc-lg +ya-fq +vi-jo +fg-dh +ax-ij +xo-ef +cr-fx +jy-oh +ua-tw +ax-bd +lq-bk +cz-ia +dr-yy +tg-rm +kg-ck +mo-wf +of-ee +qb-uf +aq-yl +jd-to +bx-qt +yz-kw +ja-pw +wq-xj +wl-xi +bk-pj +lx-vh +ma-lx +jp-bz +rl-gi +zt-do +su-nm +rz-pq +qi-jq +il-mf +iy-ru +mq-ja +lc-kh +sm-li +zt-op +nw-jr +xk-tu +fx-gq +ci-el +ub-gk +tq-ki +vc-qg +bz-ax +ok-ts +ny-gm +za-vn +bw-re +eo-if +yc-ea +tk-sa +co-oy +cw-yb +fg-hf +yk-ne +tm-wm +ui-pg +jo-ox +wu-vd +uf-ta +jk-gk +kf-dq +gc-lc +tg-fs +bg-ef +vw-jk +ex-ks +jy-ol +jv-sz +za-bt +wu-by +mo-mb +od-zz +et-fr +up-gs +yd-px +mz-mv +vl-vp +ya-kl +dc-mq +mp-lk +gk-ox +go-rn +dm-hh +yt-ep +gc-rh +dr-xa +pe-ho +qi-ie +gg-es +zt-ph +vf-qx +el-xw +lm-jh +kt-ld +cx-sy +qx-qz +hk-pf +ag-xh +gf-az +fi-ox +ss-iw +ee-fb +jw-df +rx-ax +hk-pw +nc-pl +fc-zb +tm-ft +dp-cj +rb-oe +rc-lq +ho-fm +et-cv +cd-rn +gj-fn +eh-yx +st-bl +wm-ok +zc-gd +gc-yu +xz-ot +uk-rc +wq-qz +ui-ag +wz-up +kt-sm +kz-hr +cm-ty +kk-rd +hn-nw +kl-fq +tg-sn +uz-fx +ld-fu +cr-hw +ae-sn +ns-wl +tk-no +vn-vm +xn-vw +rf-gc +tw-av +sw-vd +dg-lk +ut-fj +pw-zz +fm-hn +sx-fe +je-bc +da-xf +ml-zt +hi-tx +jr-pt +hz-hp +xt-fe +bl-yx +qf-we +wv-bs +am-jh +xf-pk +os-hh +ym-eo +wo-xb +sc-fb +ub-mf +pi-nu +aj-xj +tk-ru +uk-ao +qo-mp +rt-ck +bd-jz +zd-dp +lt-oa +xg-wo +yl-zy +eg-ae +aj-eh +ny-ti +yh-cm +tp-zv +fz-nm +oa-jb +hj-tv +ak-bm +hh-jg +pl-ey +bc-hi +ia-nc +ni-hc +id-iw +dz-yr +hu-hn +lv-lw +vk-aq +bs-xa +tg-zy +oe-tr +uu-oz +xj-lx +xt-av +yu-pz +nu-go +yz-vg +wb-yx +dc-ja +xd-xt +by-uj +ci-pk +uk-bw +jw-hs +wm-wl +gb-yh +ta-nc +sd-hg +er-sy +ze-ua +bc-dh +ry-ve +sz-td +xk-if +yi-pv +zj-si +bj-sv +ry-ds +gv-er +eu-pm +vw-ub +fp-ws +aq-af +om-su +rk-la +on-nt +ma-on +hg-ap +pz-ib +nb-jy +fn-ep +ms-rk +yi-qw +oi-ex +oh-gs +xg-xb +jp-mq +hx-ox +jr-ga +gy-xp +qt-ux +hc-wv +qj-wj +yp-xm +xx-sz +yn-hi +fi-gg +pz-ro +gy-mo +iy-uj +gu-tu +xn-jk +on-ax +te-ti +mr-sn +hm-cg +ol-af +hi-dh +am-cu +mz-uc +wu-jb +xy-et +wj-ak +aw-hc +eo-gd +hp-iw +yr-mq +ss-hz +oi-zl +ed-zi +ck-it +qg-an +nr-te +nw-ok +le-xi +zo-tx +gd-kc +fc-he +vg-ox +xh-pg +xy-ha +oy-ln +da-pn +jo-lp +ch-hu +sx-fl +df-tl +ks-zc +xj-ll +ml-kt +al-gs +yn-oq +ig-qx +zw-xm +bj-tb +px-jw +yg-ew +yo-xq +cy-uq +ao-lq +yn-ws +xy-zl +oi-cv +ze-fl +hv-pa +pi-rn +cy-on +vd-mn +dm-ie +xx-oe +iy-qs +tb-gh +vg-qh +al-wz +dr-du +ib-jk +fq-am +ae-lw +yh-tb +po-up +qg-me +uz-sk +qd-pp +lc-es +gv-gt +ro-zs +pl-ia +gr-wl +nq-ti +iy-hy +yz-rd +fl-tw +zp-qy +pe-tm +da-bu +ew-gy +ab-rd +nd-bt +cr-uz +ih-cx +xx-de +xw-pk +xg-es +it-kg +ca-lv +pz-dq +qv-lr +qy-al +an-my +pq-ao +hr-wb +fu-ju +kl-gw +fu-li +uz-qw +ip-bf +ii-nt +fz-ng +sy-qz +iw-yt +ho-ch +vl-hy +zl-ha +ld-ez +ln-lc +sw-hf +yb-ab +kf-gc +he-vg +ts-we +kh-co +zo-fg +rx-ps +fj-qg +pl-sa +mf-xn +yc-am +wv-lg +xf-ov +fr-fm +ci-me +bw-pj +dk-kp +od-px +mo-yg +tc-fz +cu-yc +za-ip +ms-la +sa-iy +am-gw +ot-vl +tj-pw +lz-fr +hv-bu +ru-ot +er-jz +pi-ux +st-aj +vi-zi +el-ha +be-qm +uv-jw +rt-ee +li-ju +pv-qd +gw-mt +id-ep +km-ux +hx-ng +rc-la +px-tt +tl-qn +pe-ok +ym-if +ld-fh +ui-fs +qz-oo +ig-nu +my-gu +ha-cv +de-tr +on-xs +tp-yy +vh-ll +st-dk +lo-nz +pg-tg +eq-zp +qq-ak +rc-pj +ij-nt +qn-un +fo-pg +br-id +dg-me +bf-he +mz-cg +mp-ry +yt-id +oc-ab +rz-lq +qb-xm +lh-uv +nd-le +mw-xd +wc-vw +tu-eo +db-xx +km-rn +kr-aa +uo-ac +am-dv +sw-wu +gi-oi +pg-gk +xx-gt +tx-ws +kh-eq +xx-td +gv-ig +cs-oz +dn-xs +jd-ie +fh-ml +ru-vp +pv-uz +qy-ef +uu-di +ds-ve +hn-cn +jp-pw +ds-xo +oa-by +my-if +he-qh +tu-zc +am-lm +jv-ud +bj-ic +ud-sz +mo-nx +ra-go +aq-fb +wl-wy +qd-sk +xa-yy +os-yq +xp-yp +xg-qp +sq-qb +qy-dg +ix-iy +qz-gr +rd-kw +vk-zh +iz-pd +ro-ss +nq-cw +we-td +zl-cb +aj-ll +zt-kt +ph-kt +lp-ox +rz-re +nb-gs +dg-ry +rk-cg +hk-bz +qg-xw +lg-zv +ct-hl +rx-xs +sh-ra +fo-ag +ga-tw +if-ga +of-zi +qq-bm +dr-hc +xa-hc +tk-vp +fq-lm +zn-lw +pq-uk +pc-lt +ee-it +pn-fj +xz-uj +ns-xi +wv-dr +qw-qd +xj-kz +am-ya +id-hz +or-dp +ib-yu +pz-gc +kw-ab +gh-pb +ia-ce +et-ex +rx-bd +kt-fu +cz-be +tn-yl +hs-tt +yy-ni +oh-wz +bl-xj +gs-un +rl-cb +ju-zt +wv-ms +rm-fs +ge-iz +qz-vf +tu-ym +kl-cu +dv-ic +ne-ae +cy-cv +hc-bs +tm-nw +tm-ho +kh-un +hj-xq +hn-pe +ab-vg +ch-pe +lq-uk +mn-iz +zd-vi +zv-zg +mq-dz +av-xd +al-up +ag-pg +gx-mo +gg-lc +tc-sd +dn-ga +eh-vh +yu-ik +ij-ma +oh-nb +ub-fi +rj-eu +tx-fp +dn-jr +zc-kc +gq-hw +wc-hx +bi-jp +hx-fi +tw-xt +hi-fg +fx-pv +bl-wb +hg-su +az-su +br-ji +wq-nj +wb-lx +vl-tk +tl-od +bk-ao +qy-nk +ih-gt +lc-co +ab-he +zg-hc +dq-rh +rf-zx +zm-ao +wo-qp +dc-dz +sk-cr +et-zl +cd-nu +rt-kg +hy-ec +oo-er +ju-ez +lv-yk +fi-wc +st-vh +gk-xn +vn-wy +ma-uc +zf-bm +cj-vi +ep-br +ij-uq +oa-mn +tu-gd +ds-yo +je-ws +kc-iy +qj-be +il-hr +op-kt +nk-qo +bd-nj +sd-om +up-ap +ma-ax +xw-me +ue-fm +fs-tn +ks-eo +tg-fo +xi-zr +nc-zw +ex-rl +ot-ix +zh-rt +qq-qm +ho-qi +sh-vb +td-hj +yh-gh +jb-ge +ss-si +vn-xi +lr-qj +xk-my +fd-un +fo-tn +kt-ju +pp-cr +gu-gx +oy-xb +xn-fi +zo-fp +mf-ox +gd-an +fo-xh +lg-xa +pc-pd +mt-am +vb-rp +eq-qp +al-en +cf-dp +kp-rl +cm-tv +nu-rp +lo-sf +du-aw +zp-qo +ab-fc +zt-ld +yd-uv +zh-it +di-ti +rb-qf +mb-mw +dt-ma +fb-ck +hl-pq +fh-ez +lo-nx +yq-jq +sh-pi +or-oh +ks-kc +hp-en +sh-km +ct-pj +zi-or +by-vd +dn-av +vl-jf +px-wn +lc-oy +dm-hv +ak-qx +yk-ca +dm-jq +ij-dt +to-qi +xa-dt +rb-we +fd-wz +rl-fr +ha-et +gd-ya +of-aq +uw-dq +pg-rm +rx-nt +jp-zz +uq-cu +yh-hj +hr-ll +cs-te +ts-ho +tr-qf +gt-vf +bw-ao +ne-eg +pb-xq +pw-dz +bi-zz +bc-fp +ed-cf +li-ml +ct-tp +wn-ac +rh-kf +do-ld +nf-cr +ov-qg +ph-op +nt-cy +tu-ks +wo-oy +ya-dv +aw-xa +il-ox +vk-fb +fu-ez +zf-be +qx-gv +lk-bg +sf-mb +uo-hs +uo-wn +ss-ep +kk-zb +bz-pw +co-es +jf-am +zd-eu +qp-lc +yu-rf +li-rf +fh-op +sj-fv +ms-cg +iz-jb +sd-fz +qv-cz +rn-ra +cd-rp +sj-ng +lt-wu +sc-it +uo-yd +dh-fp +uj-hy +cd-pi +nm-sj +fd-nb +rp-go +ex-cb +of-af +oo-at +me-da +ee-aq +tr-db +mo-sf +pc-wu +lz-kp +jw-yd +rj-zd +yh-pd +je-oq +zx-gc +uv-tt +om-fz +sm-ml +jh-fq +ns-vn +ny-yb +et-kp +ra-km +ok-cn +jb-sw +mp-nk +rt-af +zn-mr +na-rk +pu-vi +ja-bz +ag-ng +ja-tj +gw-jf +zj-br +qx-wq +gx-ew +lw-tq +zg-wv +gu-if +lp-hx +mp-xo +ee-sc +mw-nz +pz-zs +aq-ck +lx-aj +cf-pu +st-yk +bt-le +xs-jz +xx-qf +rj-vi +ix-vp +hw-pv +pn-ut +mo-mw +jl-fx +bs-dr +rm-fo +il-lp +sx-jr +kp-oi +mf-lp +df-uv +ov-el +wu-pd +cm-bj +ki-ps +de-td +hv-zr +lx-kz +wz-nb +qp-xb +fo-ml +ae-ki +ef-qo +rh-rf +in-nf +jo-vw +zf-qm +hi-na +rj-cf +mv-dx +vg-zb +we-db +de-ec +fu-sm +hj-bj +qf-sq +xf-me +km-pi +uz-gq +yc-jh +ue-pe +xb-gg +wv-du +dx-aa +rp-sh +lb-jb +zv-dr +nr-cs +lh-ac +zf-qq +uk-ct +lm-yc +fq-gw +ii-ax +hm-kr +uo-tl +gu-ks +xk-ym +jr-ua +zh-ck +ap-en +pc-sw +yo-bj +xs-ii +db-ud +rj-pm +ch-ok +nm-sd +zf-lt +sk-qw +vf-gv +np-su +pt-rl +hu-ix +hi-je +oc-bf +zc-ym +pl-gb +nm-tc +ca-er +kw-zb +jp-pf +oe-de +ui-wn +ih-wq +od-ac +pl-sq +no-hy +mr-lw +tw-dn +co-xb +ak-qm +wq-at +wc-mf +bg-ds +qv-cc +zo-kx +fg-kx +kp-ha +hi-hf +xg-co +xb-kh +me-ut +jv-we +yc-mt +gt-ig +dh-zo +eh-xj +oq-tx +nq-gm +yk-zn +it-es +hr-yx +mn-lt +wj-qd +mr-yk +hm-aa +sr-ym +it-of +xa-du +zd-zi +jw-tt +nk-bg +fe-pt +rj-sp +fs-xh +sq-uf +pw-yr +wh-in +po-un +lp-fi +zv-yy +ni-dr +yk-ps +en-jy +aa-rk +ja-yr +rm-yl +uv-wn +tg-ag +sh-rn +dx-rk +nf-yi +ea-jf +wh-gg +gy-sf +if-gd +cn-wm +xq-bj +to-pa +kc-ym +jw-uo +an-tu +hz-si +fe-tw +hf-dh +pn-pk +tl-tt +bl-dk +kc-gu +yn-je +ex-xy +en-up +gb-pb +fz-np +aw-ni +vp-sa +tb-xq +kr-la +td-qf +or-cf +nx-ew +rn-jz +mt-ey +by-jb +ok-tm +iz-lt +gx-nz +xn-hx +up-nb +yb-nq +ne-ps +du-zg +wh-ui +ig-er +qn-po +ix-sa +zw-ia +sw-by +ep-hp +bj-gh +il-gk +or-ed +eg-zn +nm-fv +nf-sk +ne-tq +zt-fh +tk-iy +sq-zw +we-xx +pe-fm +le-ip +cw-uu +zc-if +kz-st +ra-cs +rb-co +ip-bt +tj-yr +fs-wh +gs-fd +wj-lr +pl-ta +od-uo +bk-rz +ex-fr +jo-jk +jl-sk +fw-lc +hy-xz +bc-kx +da-ci +yu-dq +il-fi +yr-bi +we-tr +il-jo +cg-la +os-pa +sx-ze +fb-kg +zn-tq +bm-qm +lv-ne +ge-vd +do-li +hr-eh +bd-uq +uq-jz +hp-si +ne-ny +sw-mn +gc-ro +vm-ns +vd-lb +cw-oz +ea-cu +ct-re +qw-jl +af-kg +fm-wm +nk-ef +xj-vh +ep-si +nx-gx +ty-yg +tu-sr +rp-pj +kw-nj +rd-nj +xh-in +mr-lv +sa-xt +bs-zv +yo-je +yt-fn +lz-cv +eq-lc +xt-dn +xi-za +iz-by +kr-na +kk-qh +ns-gr +wm-nw +vb-rn +es-ln +ns-za +xf-ci +vv-dx +ym-an +kh-ln +ck-ol +xw-ut +zc-my +jl-nf +kp-gi +hv-yq +sn-lv +aw-lg +bl-aj +pw-pf +bs-yy +el-fj +it-ol +wo-co +pk-ov +lz-xy +ew-lo +uq-ii +rt-ol +ms-mz +ty-gy +vw-mf +jf-mt +kp-fr +hl-bw +gr-ip +na-qh +gv-oo +su-fz +hu-tm +op-ju +sh-ko +bf-kw +kh-qp +tx-gv +jq-jd +pc-mn +vw-fx +lt-ge +yq-pa +aq-ol +ea-am +hm-lw +eh-lx +wq-gv +sz-oe +dr-aw +jp-dc +sf-oa +oz-yb +lm-jf +fs-pg +fh-sm +xk-gu +yc-kl +oo-aa +nu-ux +pl-xp +oh-ap +ws-oq +nm-zt +ov-ut +sn-ps +qn-oh +on-jz +fe-ga +dv-ea +qo-ve +wf-sf +ux-go +ds-qo +oc-nj +fp-fc +lb-pd +bj-eg +ko-km +bl-vh +jw-ac +wy-bt +oz-di +pa-hh +iw-gj +pk-ru +db-de +sx-xt +fv-gf +mb-yg +fw-qp +eh-wb +to-os +sv-yh +ks-gd +ut-xf +xd-dn +kz-aj +qo-qy +hp-yt +nq-dr +ct-rz +qn-fd +tw-sx +zi-sp +er-vf +bi-hk +os-dm +cz-ak +ju-do +wh-xh +fl-pt +az-fv +cg-av +dh-ws +ab-qh +hl-rc +tn-ds +up-qn +ps-tq +fb-of +sq-ia +eo-zc +lr-cc +we-ud +nu-km +gm-ti +wn-yd +qj-zf +sa-hy +ct-bk +cd-qt +fz-rj +sm-sx +pb-ih +ee-ol +su-zh +la-dx +xm-uf +dn-ua +ws-zo +wz-wh +pf-yr +wq-cx +fw-xg +gx-yg +gg-qp +pq-lq +ng-hg +ot-tk +ue-ho +ds-dg +ih-qz +kk-oc +tx-kx +cx-di +bi-dc +ep-gj +ub-il +ph-do +ml-ez +pi-rp +fm-tm +dm-qs +sw-lt +ym-gu +zd-sp +fx-hw +cc-ak +ec-sz +fl-dn +at-vf +bd-ii +ci-pn +in-pg +ss-id +hi-zo +cx-oo +wf-lo +ml-op +ab-nj +yx-ll +np-ng +bm-be +jq-jg +re-pq +tv-tb +lp-vw +pb-yh +uw-pz +kr-xw +in-fs +mn-ge +eu-zi +qb-ia +tj-jp +po-en +cv-fr +gk-lp +oc-zb +he-rd +ey-sq +pm-cf +zh-aq +jg-qi +cf-eu +oz-te +pi-vb +bf-rd +br-si +di-cw +be-zr +lz-cb +bg-ve +mo-os +el-me +gj-zj +dx-uc +lo-gy +ze-fe +xw-pn +fz-az +sp-cf +fg-fp +re-lq +zy-xh +bl-eo +sj-gf +mv-na +bk-bw +px-uv +di-ny +fl-xd +fg-ko +jo-ub +le-gr +ha-ex +lm-cu +id-hp +to-dm +uw-gc +sr-eo +zi-cj +cv-xy +ws-hi +uc-vv +zs-gc +we-oe +ki-yk +ta-xm +ga-av +gw-jh +lb-iz +sa-no +qj-oq +hx-il +on-ij +eu-or +nq-cs +zy-rm +ui-fo +gi-ex +gw-jd +xz-vp +mv-vv +hk-dz +qt-km +st-lx +ce-sq +su-ng +lv-zn +cu-fq +pb-tb +uk-rz +ft-nr +jf-jh +kp-ex +gb-gh +pk-el +jl-fw +xn-il +nf-qw +zr-vn +gh-cm +ma-ii +fm-ts +pl-zw +wh-fo +ps-ae +px-uw +ik-ib +yc-jf +cb-et +gq-zj +je-tx +uf-zl +tc-az +ry-qy +tn-ui +wq-vf +ml-ph +iy-no +lo-fr +ge-lb +dz-tj +jp-fu +xw-fj +nt-jz +qx-sy +sx-ua +le-ns +xd-tw +zp-nk +yl-tg +ix-xz +lr-cz +an-xk +zm-rz +ef-zp +yp-qb +qq-lr +pp-yi +uq-ax +ds-lk +pq-bk +xf-vc +zy-wh +ec-we +ni-bs +cz-cc +vg-kk +ag-fs +xp-xm +nr-uu +dz-zz +qv-bx +fd-oh +uo-uv +ut-qg +hn-wm +pf-tj +ft-ti +ss-zj +rt-it +ut-vc +gj-hz +pm-vi +ji-yt +uq-rx +wn-hs +df-hs +of-rt +td-ud +oe-db +nt-bd +oe-jv +ti-yb +uf-ia +tj-bi +pj-pq +no-vl +qf-db +hz-ep +pt-yp +lb-wu +gk-wc +vv-mz +fr-ha +tc-fv +nr-qq +ko-cd +lr-zf +ux-ra +fc-yz +ng-fv +fq-jf +lr-bm +xm-nc +jk-lp +hm-uc +fv-sd +fx-nf +yu-uw +yt-uv +at-er +ui-yl +yt-cf +uq-dt +kl-mt +mb-ew +uz-jl +ld-sm +qm-cc +xi-gr +mo-nz +gi-xy +jq-hh +la-mz +qb-xp +uc-ms +ch-cn +an-if +qv-be +zs-dq +sv-tb +qh-oc +tm-ue +yl-fs +lk-qo +np-om +qb-nc +fs-fo +xz-ru +si-wo +uw-rf +bu-yq +fp-yn +rp-ko +ie-jg +nt-dt +yc-gw +ca-sn +te-cw +ef-dg +yc-fq +dx-ms +fb-ol +uz-fv +dz-jp +cu-jf +pn-ov +yg-nx +wj-qv +eh-kz +vm-ip +sz-rb +ie-yq +nk-ry +tm-ch +pk-me +je-zo +pt-ua +mt-fq +lz-ha +nr-gm +dq-gc +lx-dk +wy-le +ii-jz +ji-iw +re-ao +pa-gh +ki-lv +eq-oy +ng-gf +oz-ny +jr-xt +dk-vh +ch-nw +kf-ik +rl-zl +lb-mn +ub-lp +zl-kp +rd-zb +kh-oy +te-ny +fq-ue +oa-lb +jk-ox +qd-cr +po-oh +nw-ho +eq-gg +ab-kk +es-fw +av-ua +qx-at +uo-px +yu-ro +cv-rl +lo-mw +kx-hi +zo-yn +zw-yp +nm-gf +mv-cg +li-jk +tn-rm +xb-eq +cz-ot +zm-hl +hc-du +wm-ho +eh-dk +ch-wm +oa-pd +oq-kx +sp-ed +do-ln +ie-to +ps-eg +uv-tl +st-eh +na-uc +xg-oy +vn-ip +pj-ao +fg-tx +oq-zo +ty-gx +yr-bz +zw-ce +eq-co +wf-ew +nd-ns +kl-ea +kt-do +ez-ph +pu-pm +ki-ws +mp-qy +ia-xm +ic-pb +nq-te +la-hm +mt-dv +vn-bt +zp-ve +tw-km +ac-df +en-qn +ty-lo +to-oe +zs-sd +rj-dp +dt-jz +jg-bu +bg-ry +nz-ew +to-jg +xo-bg +xo-ry +dv-jh +nc-sq +sw-ge +ij-bd +un-up +kc-my +do-sm +yn-tx +xf-el +uz-nf +zx-kf +ss-ji +yn-fg +sf-mw +mw-ty +zb-yz +bw-yz +uw-ro +je-fp +ic-cm +om-az +wq-gt +nw-cn +cc-qj +zs-ib +pt-av +hh-ie +if-tu +ez-do +zl-fr +df-px +ro-rh +vv-ms +ws-hf +qp-oy +pv-sk +bm-bx +yd-df +qs-tk +hg-np +ih-vf +iw-br +qg-pn +pm-sp +wf-mb +bx-be +pv-cr +xs-ma +ft-uu +zh-af +dm-pa +jg-dm +cn-pe +lg-du +kf-pz +ps-zn +sp-pu +dx-st +pj-uk +wo-eq +kg-mq +od-tt +or-pm +eg-ki +ta-qb +cy-bd +yc-ew +bl-kz +kf-zs +nm-hg +db-jv +nx-ty +ve-mp +aj-vh +mq-bi +zo-hf +yi-fx +pe-wm +ca-ps +bz-zz +pb-bj +lh-wn +vb-qt +bi-pw +ck-af +yd-od +ck-sc +en-gs +ft-cs +ph-li +zz-yr +nb-un +hx-jk +xk-sr +nk-ve +zg-vf +vi-or +tp-xa +ko-ux +yi-hw +ig-sy +pc-by +df-od +eo-xk +sr-if +ts-wm +pu-cj +uo-lh +cs-gm +ny-cs +yt-zj +cr-bg +bm-kk +eg-ca +hm-mz +uz-qd +qs-uj +ll-lx +kx-ud +bf-fc +sy-vf +rb-td +un-en +ie-pa +wl-nd +oh-un +tl-hs +cc-zf +on-uq +ts-nw +ux-rp +gm-di +lp-wc +dz-pf +sv-xq +yz-he +cg-na +tj-bz +yz-nj +nw-pe +gj-ji +ub-lh +oc-he +wq-sy +ec-jv +te-yb +pu-zd +xy-hh +lc-xb +hf-bc +wb-vh +eg-tq +hs-lh +lw-ki +id-xo +ac-hs +jr-xd +xg-eq +ip-zr +sf-ew +vb-nu +sn-lw +ng-om +uf-ce +do-ml +rx-cy +rt-kt +lt-pd +kl-jf +sx-pt +qy-bg +hg-tc +fr-cb +il-wc +fh-li +he-eh +kw-oc +gt-at +st-hr +lb-by +uz-yi +hx-jo +aw-wv +qb-pl +xh-tn +xk-ks +hs-qo +nz-wf +lz-gi +ft-cw +wv-xa +qo-ry +nx-mw +fn-si +fm-cn +rl-lz +yc-ya +ns-db +hj-cm +ap-fd +fj-ov +nu-qt +le-za +dp-vi +jd-yq +mr-ki +ha-rl +zj-hp +ie-os +pt-ga +yp-sq +jg-yq +sd-su +ja-cj +uk-zm +pp-jl +dx-kr +ib-gc +li-zt +mr-eg +sn-ne +ry-lk +ae-mr +eu-cj +po-jy +tv-xq +na-hm +go-km +ju-ph +me-fj +ss-hp +di-te +gs-po +vi-ed +la-na +wu-oa +yo-hj +xk-kc +hv-jd +ox-xn +ni-zg +sf-gx +fp-oq +ew-mo +zj-hz +zo-hw +zs-rf +ko-pi +qq-qj +rb-ec +tn-zy +fg-ws +ds-zp +pe-ts +af-pz +lx-bl +nc-uf +nk-xo +ld-ju +hh-hv +fs-no +wy-vm +xd-ze +ru-wy +ki-zn +ef-lk +ui-xh +fe-ea +az-nm +vn-wl +tc-ng +ji-dc +hu-pe +wn-tt +lv-de +ze-jr +ix-ru +oo-ig +op-do +sd-sj +hv-jq +gb-tv +nb-al +xi-vm +hj-gh +cg-uc +cv-gi +in-tg +hw-nf +zt-fu +ta-ia +rx-jz +es-wo +tx-bc +vk-ee +eu-vi +in-rm +rz-hl +rn-rp +uw-zs +ze-dn +wy-xi +hy-ru +pm-zd +fg-je +zy-pg +no-qs +oo-ih +jz-cy +on-ii +pg-wh +gs-qn +lm-ya +ut-el +bt-wl +zb-qh +it-af +oi-rl +ch-ue +ez-zt +vc-da +oa-sw +ie-jq +np-nm +om-gf +dp-pu +rc-bk +mz-na +ua-xd +jw-wn +jd-dm +et-oi +xg-ln +ub-hx +pm-zi +bi-ja +ua-fl +dk-kz +zs-rh +yd-xb +qs-vl +kg-zh +ua-xt +ez-kt +wq-oo +rn-ux +an-mv +hy-vp +of-ck +qp-es +jy-gs +fl-xt +sj-om +ks-pu +qz-cx +yg-lo +rk-uc +zy-mq +rx-dt +dc-yr +sx-ga +lv-ps +go-vb +ea-lm +vl-xz +iz-oa +xm-sq +if-ks +zx-lk +yz-oc +nx-vp +tr-ec +pn-vc +iz-pc +gk-fi +mf-fi +cw-mn +nx-mb +ax-nt +ik-sy +xf-qg +qm-lr +ma-uq +it-fb +jg-os +ot-vp +po-wz +ju-ml +on-rx +az-hg +zb-ud +zv-wv +uu-tc +we-de +cv-zl +ui-in +rm-wh +xy-fr +lt-lb +ji-si +ax-dt +os-jd +es-oy +il-sc +oq-hi +il-vw +cz-qq +lg-bs +nf-gq +xg-kh +qh-bf +hm-dx +gy-mw +ti-oz +lb-pc +ae-zn +cs-ti +cy-dt +rc-re +eg-yk +da-pk +du-tp +bu-pa +eo-my +bk-jq +qw-fd +uv-ac +aq-sc +qv-qj +ho-hu +ci-ut +rn-qt +qy-xo +nj-bf +sn-yk +lz-et +tt-mb +zy-ui +dp-pm +fh-kt +oc-rd +rh-pz +tv-sv +ta-sq +jl-gq +bx-ak +ni-tp +ip-nd +ra-vb +yh-xq +yq-yr +xs-nt +ra-rp +jr-av +ab-yz +zh-of +zg-lg +fd-jy +gi-pq +ma-cy +pn-ii +mb-lo +pj-hl +hr-aj +di-yb +xh-gj +ik-gc +ny-uu +qs-ru +mr-lb +tn-in +aa-la +jg-vd +bf-zb +hz-sj +gr-za +vw-gk +ap-al +zi-dp +ee-ck +zp-dg +qw-pp +bl-hr +qz-ig +pf-dc +fg-bc +zj-ep +kh-wo +sn-zn +jh-wu +ko-go +gf-sd +ib-zx +jk-fi +kr-mv +bu-ie +cw-gm +ry-zp +ae-ca +hn-sr +cu-gw +st-ll +lz-oi +ga-xt +ec-td +qg-pk +gk-mf +ln-fw +vb-cd +qo-bg +bc-ny +ib-kf +zr-wl +oi-cb +pv-dz +am-ci +sf-nx +mv-ms +la-vv +xf-ni +cu-ya +hw-qd +dn-ao +wf-ty +yp-ia +zd-ed +nz-gy +qx-er +jh-ea +gy-yg +xh-rm +jr-fe +gy-mb +le-wl +hj-sv +dx-na +ih-qx +bz-pf +lr-bx +fn-zj +vb-ko +ik-pz +tr-jv +jz-ij +sy-at +uw-rh +to-hv +az-np +bu-dm +pv-jl +ip-wl +cm-gb +pg-yl +ms-hm +cj-ed +by-mn +kw-he +ce-nc +zr-ns +tn-tg +gt-qx +gt-er +cc-aw +bw-zm +ce-qb +fw-co +yc-bt +qi-os +qn-nb +al-un +tb-cm +ni-du +xs-ij +yy-aw +ln-qp +jl-hw +yi-cr +bx-wj +ey-zw +xk-zc +ic-yo +wf-nx +vk-sc +sj-fz +ue-ts +sc-kg +en-nb +zi-rj +lv-tq +si-id +eu-sp +aq-kg +re-uk +qq-qv +me-vc +xx-tr +wf-mz +rz-pj +es-xb +lk-zp +dc-hk +mp-bg +ui-tg +br-hz +pp-hw +li-ld +ju-sm +sp-vi +ov-xw +pd-vd +kc-tu +iz-xi +yx-lx +fz-gf +pz-zx +qn-al +rj-xg +xa-zv +uc-la +xq-gb +yg-cn +go-qt +gj-yt +zr-bt +ns-bt +al-oh +nu-ra +sx-dn +ux-rk +an-eo +dt-on +rf-pz +fd-po +hf-kx +kw-fc +iy-vl +da-ov +yp-ey +fw-eq +sd-az +mr-tq +uz-pp +af-vk +qs-ix +kr-cg +pc-oa +an-sr +cn-ue +ag-yu +qj-cz +zc-ij +yh-bj +oa-vd +hp-gj +xw-da +dk-hr +it-vk +vv-cg +qg-ci +zm-ct +ja-hk +tl-px +ey-ce +yu-kf +ue-nb +bm-qj +ks-ym +ue-ok +ac-tl +hy-ix +rk-kr +rb-de +rz-ao +yx-dk +cy-ii +hu-cn +nd-wy +gr-vn +yl-wh +ee-zh +wy-gr +ha-gi +aw-tp +wc-br +yy-lg +mz-aa +ap-po +tc-gf +po-nb +zn-du +yg-wf +hh-jd +ln-xb +el-qg +wn-tl +jz-ax +hv-jg +wz-jy +zz-dc +zl-lz +cc-qq +cf-zd +hj-tb +qt-ko +xz-iy +ro-kf +gs-op +mv-rk +ji-zj +or-pu +ct-lq +yu-zs +rc-vc +ho-cn +qh-rd +qv-tv +kk-bf +nj-he +kk-ut +zc-gu +cd-ki +xn-wc +qh-nj +lz-wu +nr-yb +xd-pt +te-vn +ge-by +cw-ti +zo-bc +gq-pp +rh-yu +uc-mv +wf-mw +te-gm +fu-ph +ib-rf +tj-zz +zd-nf +nd-yn +jo-fi +jo-xn +cr-gq +cs-cw +dq-xm +oy-fw +gq-qw +ij-cy +yo-tb +zf-bx +bz-bi +ey-ia +aj-yx +wv-yy +ib-uw +gb-wm +tp-hc +ey-qb +nd-zr +gv-at +km-cd +os-bu +le-vm +qv-ak +tl-yd +kw-vg +ya-jh +hl-lq +sz-lr +ge-pd +ko-tu +bi-up +ld-op +re-pj +jy-qn +ih-er +da-yx +ih-sy +aa-ms +fj-ci +tp-lg +tm-ts +fc-vg +ea-fq +zj-iw +or-cj +yn-wb +sn-eg +jy-un +op-li +fj-sh +fz-fv +no-xz +hk-jp +mt-cu +lh-tl +ya-gw +mt-jh +sh-nu +ph-ld +ve-np +hr-xj +go-cd +ix-no +pj-lq +pa-qi +xs-dt +sa-vl +qb-ie +ze-pt +ho-ok +zx-ik +yb-uu +vk-kg +eq-es +sn-tq +fe-ua +hx-vw +zb-ab +yo-tv +wf-gy +hz-fn +aa-mv +pb-sv +an-zc +qt-pi +cs-yb +ik-ro +xs-cy +cb-xy +rt-vk +vl-ix +gj-br +jr-tw +mr-ne +fw-xb +xy-oi +my-ks +kl-jh +qm-wj +ud-rb +uf-pl +br-ss +ey-xp +sr-zc +qp-co +vm-wl +gm-uu +lo-mo +wn-df +rh-ik +vg-oc +yi-sk +bl-eh +kh-fw +sf-nz +xi-ip +jv-de +fm-hu +pd-sw +ji-hp +ze-hv +ic-tv +mw-ew +ma-rx +sr-my +fl-vh +ca-zn +pp-fh +ct-rc +be-cc +ag-in +sc-rt +mq-hk +in-zy +yt-hz +ga-xd +tn-ag +ss-fn +yd-tt +mz-rk +kx-ws +hc-df +uj-ix +aj-wb +ex-zl +xs-ax +ep-ji +tk-hy +ag-rm +os-jq +qn-ap +nd-za +ga-ua +xh-yl +ef-ry +ig-ih +bt-xi +ce-xm +hg-fv +ic-gh +of-vk +bx-qm +fw-gg +op-ez +ge-pc +hf-oq +uj-ru +fv-np +vv-cb +pk-ut +xn-lp +qd-fx +jk-mf +xd-sx +zm-pq +gx-mw +oz-ce +qm-ok +gt-sy +wc-jo +sv-cm +xq-ic +ac-yd +tr-sz +zj-id +ro-zx +pp-sk +nc-pe +qs-ot +vc-pk +dq-ro +xj-wb +iy-ot +zv-tr +uc-kr +sk-uv +hf-je +ig-at +si-iw +cf-zi +lq-zm +bf-ab +hv-ie +vp-no +jl-qd +cv-cb +lt-by +fd-up +le-ta +rc-pq +yt-br +sh-qt +ce-ta +bs-zg +ip-ns +cj-cf +fs-zy +la-mv +tx-dh +of-ol +ic-hj +gx-mb +jo-mf +dx-cg +fp-hf +iw-hz +mq-pf +tt-ac +pf-zz +oo-qx +ez-li +hx-mf +lb-sw +kh-es +zr-le +yu-zx +rj-pu +pq-ct +xg-gg +up-jy +ji-id +xy-kp +ca-ki +cx-at +zh-sc +ed-rj +to-jq +zf-ak +ze-xt +aj-zg +gq-qd +st-yx +mp-dg +tv-pb +fh-ju +od-hs +kf-eu +zp-mp +dq-ib +qv-qm +ey-uf +hp-fn +cx-ig +do-fh +lt-vd +xj-yx +jd-qi +cj-pm +gd-my +zl-gi +yg-mw +ch-hn +vh-yx +on-bd +fc-qh +vw-ox +sm-ph +pc-xx +yq-qi +zf-wj +xj-dk +le-vn +qo-dg +km-vb +yl-fo +zw-xp +sd-np +uo-ju +nz-mb +uz-hw +bd-dt +od-wn +hf-tx +rf-ro +ny-cw +kr-mz +xw-vc +td-oe +zg-dr +zb-nj +bx-qq +gb-ic +co-gg +wh-tn +av-ze +tk-ix +fb-rt +qs-xz +sm-ez +oq-dh +uq-nt +ci-xw +ub-jk +wo-gg +az-tj +at-qz +sc-ol +no-ru +tj-hk +gu-sr +lv-ae +bz-mq +kg-of +od-uv +nz-yg +fi-vw +xp-uf +rl-xy +ty-mo +gr-nd +ui-rm +yk-lw +zp-bg +eu-pu +ub-xn +zm-re +op-sm +oa-ge +kw-ne +kz-yx +hp-br +ih-gv +qb-zw +oq-bc +mf-pf +hz-ji +qt-ra +yi-gq +cm-pb +ms-na +xs-uq +rn-ko +yp-ce +rj-or +iw-fn +jr-fl +ss-gj +vh-hr +rh-ib +dp-rm +rl-et +eo-gu +ci-vc +bu-hh +ni-lg +bs-dh +tv-gh +yo-sv +mz-dx +tm-hn +xp-ia +wq-ig +nf-pp +ub-ox +am-kl +cj-ef +fl-av +sr-gd +cf-vi +cd-sh +pl-ce +gt-oo +cw-nr +kg-ol +iz-sw +sq-xp +bf-yz +te-ft +be-lr +su-tc +qw-cr +sy-oo +lc-wo +ap-un +tg-xh +dv-kl +ya-jf +ag-zy +pv-zs +et-tk +kh-gg +ft-di +oe-ud +cs-di +cb-gi +kp-cb +qz-er +rd-fc +aj-dk +pi-go +sk-hw +or-zd +dn-fe +yh-yo +pv-gq +nk-ds +kc-an +wm-hu +xx-ec +tt-lh +ll-eh +qf-ec +bw-rz +xz-sa +fq-dv +vd-pc +ag-yl +to-bu +vk-ol +qg-ua +zg-tp +ux-sh +cc-bx +gh-xq +kc-eo +ue-hu +vm-zr +rb-tr +sz-we +eg-lw +kk-kw +vg-rd +ep-vk +rk-vv +pw-dc +xk-gd +xw-xf +ao-ct +de-qf +wj-cz +zv-hc +ot-no +dq-rf +kx-je +dq-zx +cs-uu +pd-jb +hl-bk +rh-oh +vd-jb +bt-gr +vb-ux +ov-vc +kf-rf +ze-tw +lm-dv +vm-tq +cx-er +bs-aw +gj-id +mn-pd +bs-tp +ge-iw +ae-bx +st-wb +gw-lm +db-rb +hj-gb +yl-in +nk-lk +cx-gt +cd-ra +re-hl +nw-fm +ym-my +si-ez +yg-sf +hu-ok +ve-lk +ki-sn +oi-ha +hx-gk +td-db +nk-ee +fj-da +sa-ot +zh-fb +ca-mr +db-sz +xt-pt +qv-zf +en-wz +hg-om +up-za +ve-ef +uj-no +hs-yd +bu-qi +qn-wz +wj-bm +zm-rc +bj-tv +zw-bc +gv-qz +ph-qy +nz-ty +vc-fj +lx-hr +it-aq +fm-ok +hy-qs +ve-dg +gf-hg +jb-mn +dh-je +hn-ts +lr-ak +gf-su +fx-pp +pb-yo +mp-lp +oz-nr +qp-nm +vd-iz +lm-lq +xq-cm +dm-yq +dv-oi +al-po +xx-rb +ea-gw +xo-zp +ov-ci +zx-hk +jy-ap +hh-yq +ng-sd +px-hs +br-fn +ic-tb +nc-xp +gx-gy +td-tr +kc-if +gm-ft +kw-qh +tq-ae +el-vc +ro-ib +ex-cv +yh-ic +pc-jb +ft-yb +cn-ts +yi-fb +el-da +nx-nz +ns-wy +bd-ma +sc-af +hl-ao +ii-rx +ge-ch +pa-jg +sc-of +om-tc +yr-jp +uj-vl +sj-tc +za-wl +en-fd +hg-fz +fn-ji +ds-ef +tq-yk +uw-ik +ty-ov +ao-on +oi-fr +hf-yn +bl-ll +uj-sa +aq-rt +kl-lm +qo-xo +wz-ap +zt-sm +uo-df +aa-vv +gv-cx +ne-ca +lo-gx +pp-pv +ft-ny +wu-mn +be-ak +qf-sz +ne-zn +bu-jq +si-gj +yy-hc +yp-pl +ty-sf +cj-sp +nt-ma +fe-fl +gg-ln +nq-oz +qi-hv +my-tu +nq-uu +cx-vf +ij-rx +sj-hg +xz-tk +wj-qq +gr-zr +ve-qy +ck-hs +ik-zs +nu-rn +xf-pn +ga-ze +td-jv +af-fb +po-xn +nq-nr +he-kk +ps-mr +om-nm +nb-ap +ln-co +nf-qd +zz-hk +dc-tj +xx-jv +yp-nc +vv-hm +dq-ik +oo-vf +rd-lg +ta-zw +yd-lh +pw-ry +op-fu +ed-ac +tg-wh +zg-aw +pn-me +lh-od +cn-tm +hn-ho +sv-wy +gs-wz +qt-rp +ue-nw +kz-wb +gf-aa +cu-dv +ga-fl +om-fv +ux-cd diff --git a/aoc2024/src/day23.rs b/aoc2024/src/day23.rs new file mode 100644 index 0000000..49cb067 --- /dev/null +++ b/aoc2024/src/day23.rs @@ -0,0 +1,174 @@ +use aoc_runner_derive::aoc; +use itertools::Itertools; + +struct Graph { + nodes: rustc_hash::FxHashMap>, + connection_map: [[bool; Self::SIZE]; Self::SIZE], +} + +impl Graph { + const OFFSET: usize = (b'z' - b'a' + 1) as usize; + const SIZE: usize = Self::OFFSET * Self::OFFSET; + + #[inline] + fn parse(input: &str) -> Self { + let mut connection_map = [[false; Self::SIZE]; Self::SIZE]; + let nodes: rustc_hash::FxHashMap<_, smallvec::SmallVec<_>> = input + .as_bytes() + .chunks(6) + .fold(rustc_hash::FxHashMap::default(), |mut acc, connection| { + let nodes = unsafe { + [ + Self::OFFSET + .unchecked_mul((connection[0].unchecked_sub(b'a')) as usize) + .unchecked_add((connection[1].unchecked_sub(b'a')) as usize), + Self::OFFSET + .unchecked_mul((connection[3].unchecked_sub(b'a')) as usize) + .unchecked_add((connection[4].unchecked_sub(b'a')) as usize), + ] + }; + connection_map[nodes[0]][nodes[1]] = true; + connection_map[nodes[1]][nodes[0]] = true; + acc.entry(nodes[0]).or_default().push(nodes[1]); + acc.entry(nodes[1]).or_default().push(nodes[0]); + acc + }); + Self { + nodes, + connection_map, + } + } +} + +#[aoc(day23, part1)] +#[must_use] +pub fn part1(input: &str) -> usize { + const T_RANGE: std::ops::Range = + (Graph::OFFSET * (b't' - b'a') as usize)..(Graph::OFFSET * (b't' - b'a' + 1) as usize); + let graph = Graph::parse(input); + let mut visited = [false; Graph::SIZE]; + T_RANGE + .filter_map(|node_a| { + if let Some(connected_nodes) = graph.nodes.get(&node_a) { + visited[node_a] = true; + Some( + connected_nodes + .iter() + .enumerate() + .map(|(i, &node_b)| { + connected_nodes + .iter() + .skip(i) + .filter(|&&node_c| { + graph.connection_map[node_b][node_c] + && !visited[node_b] + && !visited[node_c] + }) + .count() + }) + .sum::(), + ) + } else { + None + } + }) + .sum() +} + +#[aoc(day23, part2)] +#[must_use] +pub fn part2(input: &str) -> String { + const EXPECTED_LEN: usize = 14; + let graph = Graph::parse(input); + graph + .nodes + .into_iter() + .fold( + ( + smallvec::SmallVec::<[_; EXPECTED_LEN]>::new(), + [false; Graph::SIZE], + ), + |(max, mut visited), (node_a, connected_nodes)| { + if visited[node_a] { + return (max, visited); + } + let current = std::iter::once(node_a).chain(connected_nodes).fold( + smallvec::SmallVec::<[_; EXPECTED_LEN]>::new(), + |mut current, node_b| { + if current.iter().all(|&c| graph.connection_map[node_b][c]) { + visited[node_b] = true; + current.push(node_b); + } + current + }, + ); + if current.len() > max.len() { + (current, visited) + } else { + (max, visited) + } + }, + ) + .0 + .into_iter() + .sorted_unstable() + .map(|node| { + format!( + "{}{}", + char::from(((node / Graph::OFFSET) as u8) + b'a'), + char::from(((node % Graph::OFFSET) as u8) + b'a') + ) + }) + .join(",") +} + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + const SAMPLE: &str = indoc! {" + kh-tc + qp-kh + de-cg + ka-co + yn-aq + qp-ub + cg-tb + vc-aq + tb-ka + wh-tc + yn-cg + kh-ub + ta-co + de-co + tc-td + tb-wq + wh-td + ta-ka + td-qp + aq-cg + wq-ub + ub-vc + de-ta + wq-aq + wq-vc + wh-yn + ka-de + kh-ta + co-tc + wh-qp + tb-vc + td-yn + "}; + + #[test] + pub fn part1_example() { + assert_eq!(part1(SAMPLE), 7); + } + + #[test] + pub fn part2_example() { + assert_eq!(part2(SAMPLE), "co,de,ka,ta"); + } +} diff --git a/aoc2024/src/lib.rs b/aoc2024/src/lib.rs index 2442127..9748658 100644 --- a/aoc2024/src/lib.rs +++ b/aoc2024/src/lib.rs @@ -22,7 +22,7 @@ pub mod day19; pub mod day20; pub mod day21; pub mod day22; -// pub mod day23; +pub mod day23; // pub mod day24; // pub mod day25;