From 096208c2e570565919427ad39aa022df023df27a Mon Sep 17 00:00:00 2001 From: monoid Date: Mon, 23 Dec 2024 15:39:05 +0900 Subject: [PATCH] Add solution day 23 --- day_23/example.txt | 32 + day_23/input.txt | 3380 ++++++++++++++++++++++++++++++++++++++++++++ day_23/solve_1.ts | 44 + day_23/solve_2.ts | 53 + 4 files changed, 3509 insertions(+) create mode 100644 day_23/example.txt create mode 100644 day_23/input.txt create mode 100644 day_23/solve_1.ts create mode 100644 day_23/solve_2.ts diff --git a/day_23/example.txt b/day_23/example.txt new file mode 100644 index 0000000..d8576a8 --- /dev/null +++ b/day_23/example.txt @@ -0,0 +1,32 @@ +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 \ No newline at end of file diff --git a/day_23/input.txt b/day_23/input.txt new file mode 100644 index 0000000..ce05800 --- /dev/null +++ b/day_23/input.txt @@ -0,0 +1,3380 @@ +rm-nt +fn-mb +km-iw +hs-nu +uo-aw +xa-yn +vb-sg +pi-uc +kx-if +rw-yi +mo-at +uf-db +jj-np +is-zx +mf-jk +dj-kb +jx-ta +om-wj +tj-oc +dt-va +cn-wj +fy-dw +kl-jo +vv-bt +pp-va +pe-yv +gk-tv +vr-mu +sc-mi +na-py +cf-xh +zc-my +sc-cu +ll-xh +cq-yt +na-wb +cb-st +id-bl +tn-sg +kb-fu +nj-kj +tb-cb +jq-wi +ja-qa +kv-im +fz-qf +gj-uo +qt-qr +as-cj +li-sr +fa-fb +sy-zp +zc-pb +ue-sm +sv-zl +ts-du +um-us +od-md +kv-xp +ze-qb +rb-rg +mc-zx +ab-le +kw-mg +ay-px +tp-om +fy-hh +nt-bg +uk-in +it-qr +mc-eo +gs-dw +md-gj +oy-so +jc-rg +hi-ke +jg-yc +dx-ke +dw-ps +wi-oh +cw-uo +fn-kt +kl-gr +fw-sc +vt-sc +la-rt +qj-gl +qj-xm +xx-pf +wc-ns +hp-ng +jb-if +uc-ey +be-of +nf-si +qc-jn +lo-qh +hg-uf +js-bc +sn-yi +kh-ln +gi-dp +ss-tj +xn-vq +bp-ng +il-yg +sq-wr +ls-px +ji-ba +ga-gp +qp-ih +fd-dt +dw-ia +rs-lt +mi-cu +sy-tv +pv-fd +ya-xh +gj-wa +us-yz +uy-ki +lb-vl +ew-ws +rm-nm +cd-ii +ht-oq +kb-wi +va-do +ud-xn +ky-nq +wr-yk +eq-ph +hs-zt +df-xf +ic-kw +ss-xo +iv-hg +rd-ya +bm-or +ew-uq +ix-gj +cd-ye +gs-ia +zs-hp +fm-yx +xy-gd +zb-by +at-vo +xj-uv +tw-iy +pf-zc +nc-ij +al-uw +ke-ac +oi-kx +ud-bs +qo-kc +to-bh +hb-gz +in-xr +se-ua +mc-in +jh-dp +ii-uz +xr-oj +yi-mr +rl-rh +gs-wv +ub-nd +id-np +rt-ek +gg-to +jf-aa +kr-il +gi-cy +jo-xn +ra-of +rw-ie +rp-eg +jc-yv +ac-fu +sh-ky +ed-zw +ku-od +ic-fl +pe-fm +am-te +gr-le +ed-fo +dx-my +nl-ln +xz-wq +gc-gq +vv-wh +jo-bx +gc-ql +re-sc +lo-wu +vo-wi +lm-fw +uo-ym +zi-wr +ls-ch +vn-ij +qh-up +fw-vt +ll-nf +et-ew +br-nj +yg-rf +be-ra +ds-zd +fn-jx +bz-ny +my-ob +es-qt +ir-tv +tx-ks +aq-ie +jn-my +vx-qa +md-qu +rf-mm +rw-mt +dk-ss +wf-jr +nd-tg +jj-ed +eb-pu +hg-ho +qb-xx +rf-ik +ux-nt +dl-fb +tn-zm +cj-ic +qo-qc +jd-ab +ac-jq +ze-dj +jq-fu +tg-ub +sw-mc +bb-iw +mu-vb +ue-ep +zn-bj +wh-rp +ye-qx +if-jw +xm-rl +re-vt +ym-gz +mm-uw +js-up +vr-vb +cs-tx +qr-fw +zd-wv +su-ty +xm-gl +sa-ii +zo-ch +tw-gh +lm-fy +xm-lq +sf-dd +iq-ux +mm-pc +lh-ud +sl-tp +an-xw +bq-uk +bb-oh +mj-to +km-hu +ri-mf +hl-fk +nj-av +cf-lx +gp-lk +wj-jh +nd-sh +yc-ne +mh-kn +du-sy +uq-qg +xs-md +il-so +hs-pq +zo-ln +au-xd +kh-tk +bz-qj +yy-tr +en-bk +ph-ue +xd-pe +xf-fo +tp-bo +qm-fa +kt-gp +us-kf +fo-hp +on-yj +ue-us +ot-uz +nc-vz +os-sf +um-ph +ez-yo +fq-jc +yx-fa +sv-cf +px-ao +nt-nm +vd-oc +kh-nl +yg-al +gz-ix +mh-ui +de-vz +rm-wy +zd-xf +rl-zc +mc-oj +yv-mw +ok-ez +vj-av +sf-rs +dl-bm +as-ih +ux-rm +ah-yr +li-iq +uz-sa +tr-wq +nt-iq +mr-ie +rm-ny +dt-nj +xa-lx +hw-lt +ux-rp +hu-jp +vc-gq +va-vb +ok-nc +xz-hd +qj-og +kh-ch +su-dp +oa-lo +ig-qm +au-fm +tx-pu +qv-rg +kf-sz +yg-oy +cy-cn +iy-rt +eo-dy +ul-as +uf-zp +gz-uo +qt-el +ij-mw +ia-qq +mj-mu +us-sz +up-sf +zd-df +kh-ls +hb-ym +jc-oy +ma-wd +wd-kb +bj-do +yz-sz +aa-iq +ay-ls +zv-lf +eg-nz +nn-ye +ya-lx +lw-di +zv-gq +le-go +nd-nq +ka-xv +dt-br +gz-kw +ic-xg +pa-ng +fy-ia +ix-wa +xw-ri +xj-qv +ba-mf +oy-fc +tm-ew +aq-mt +gt-qo +ws-sq +at-lh +el-pu +ke-nq +lw-xm +sg-mu +qm-dl +aa-rm +zq-ss +lw-oi +ew-qg +pp-zo +wp-lk +ds-df +nr-en +mr-mt +xn-mo +sn-aq +nk-db +ng-tf +eq-zj +yg-so +sl-ca +ay-aa +qo-pf +tw-as +zx-uk +lk-ta +bl-np +ui-kw +ec-ja +st-lz +lg-nu +xo-om +nw-fs +hi-gl +ku-ix +wh-ib +fk-rc +wq-hl +xi-js +be-ez +gg-bb +it-re +ma-vo +xi-qh +et-zi +tn-mu +qq-fy +jm-ln +zh-wp +om-oc +et-ws +vq-kc +ei-uk +ah-sg +zb-aq +pi-ci +pa-xw +rf-uw +wk-la +cy-qa +xg-mh +hu-vo +ci-ae +wv-qq +hc-lv +gm-zu +tl-nk +rn-yo +ga-jx +qg-cl +sc-ce +bv-nf +ft-jm +ts-qf +fz-yp +fc-kr +zh-er +te-rw +py-mw +nt-li +kt-ga +mg-vl +wz-fz +ma-oh +vl-kw +up-xi +ho-uf +cy-ji +fq-yv +hs-jx +nw-ic +ek-iy +bb-hu +ka-fw +fk-wq +uy-hj +vn-yo +zj-uh +qa-yn +kq-gi +gl-to +bp-zw +jb-jw +yk-uq +wq-de +se-wz +ba-nz +vj-pt +vn-mt +qv-au +cb-cn +bc-qh +ht-lv +du-zm +lm-gs +dm-sa +jj-zw +bl-zw +li-bg +ya-kv +vo-fu +vf-vl +cc-pv +up-oa +fn-gp +ab-ow +kq-su +db-yt +cv-qt +xo-dk +ja-ty +js-gc +og-to +zb-rw +lb-fl +zh-wg +bg-jf +jn-xx +aa-ux +vo-kb +ma-wi +hb-md +iw-jq +ab-bx +od-aw +is-bn +bd-di +qb-my +vf-fs +ge-yi +zt-uk +fd-kj +vl-nw +ep-be +tp-vd +dd-ya +ka-re +cw-aw +dc-bk +nm-vw +hm-mj +yt-kz +nq-yc +im-lx +rz-ws +yj-sv +sc-po +ha-if +gf-mr +ts-vv +yo-xg +uy-ak +vz-tr +gg-eq +po-re +zi-yk +ht-gx +bt-zm +bd-if +mh-fs +yt-iv +gk-cb +sw-uk +wp-wg +vx-ty +uq-rz +tj-zq +kl-sd +aw-cd +ah-vb +dd-wu +ed-ng +ub-nq +su-qa +bs-vq +zi-rz +xr-uk +ow-jd +va-br +xt-zu +as-qp +wj-qa +xi-ib +ir-sy +yy-uo +ix-md +el-ll +zn-jw +fq-uv +nj-pv +ub-yc +jh-ja +dc-we +le-sd +zw-id +ix-hb +tj-vd +ch-ao +gl-bh +br-da +pv-dt +xu-nq +cw-gj +ko-go +oa-sf +bx-ow +ix-aw +rn-kj +ua-bt +pi-en +sr-ms +kw-nw +il-rc +lg-bu +ps-df +jo-ce +yz-kk +fm-xd +do-jw +bp-np +qh-oa +yi-mt +ql-gm +rz-et +rp-nz +rc-xz +fb-td +sj-pq +yt-hg +ye-uz +dx-ky +iw-kb +lj-uc +en-lj +np-ee +vn-un +mm-jp +xa-rd +fr-gt +tk-ft +ii-pq +rg-pe +fd-da +vx-wj +sv-xh +ba-cq +lv-zk +we-du +hb-gj +iy-ul +cq-yj +xg-fs +bc-xi +uh-ue +db-kh +ef-zp +ja-dp +cd-dm +wg-kt +vn-ez +lg-xy +dm-py +pi-ak +ux-ny +sd-go +gk-up +vb-wt +jx-lk +ao-qc +ye-dm +hj-ae +jf-ny +kx-ty +wk-xy +jq-hu +mc-bq +ss-os +wa-ym +ql-xt +xt-zv +go-ab +kl-ko +od-gj +nt-lu +tx-cv +zw-ee +on-nk +oo-gp +oh-wd +jv-xe +kz-er +bm-ig +km-vr +my-pb +qc-ob +ze-bd +hm-ru +vr-ru +hz-in +kt-ta +hg-eh +le-ob +aa-wy +rs-hw +vz-wq +ll-cs +hb-cw +oa-dd +jq-jb +hp-ee +fx-pq +qo-pb +hf-sh +bn-fb +eo-in +gg-lq +fr-tn +eq-kf +sl-qj +uz-qx +so-mm +nc-un +fz-du +oa-wu +ls-pt +td-fa +ka-mi +um-eq +bn-qu +rt-as +vf-wv +ne-br +ds-lm +dm-mw +ua-qf +py-cd +dw-xf +gt-vb +bp-tv +ce-ka +ay-zo +zv-vc +xj-au +vg-qf +bt-qf +cf-im +jr-ez +re-ce +qc-zc +md-aw +ow-ko +sd-gr +ww-sy +pb-zq +fp-dp +en-ci +ku-cw +uo-md +bs-lh +bm-ky +ta-oo +iq-jf +sg-mj +nj-pp +ew-sq +xs-gj +xe-ow +jl-jb +gd-fx +uv-au +po-mi +bb-wd +ne-va +gz-ku +jx-mb +xs-hs +nw-xg +wv-ds +tm-il +oo-mb +ek-la +ao-nl +vx-cy +xk-ew +zs-ee +ir-ww +wh-pa +de-tr +gr-sh +tf-ed +er-lk +pt-gl +ls-ln +cj-ul +ee-bl +px-kh +oo-jx +xg-ui +mg-fs +ns-fa +fy-sd +fu-uy +ho-cq +lm-zd +xi-lt +fo-id +ze-kc +ib-rp +kr-jp +il-al +pq-nu +vw-zp +pc-cj +jb-mi +pq-xy +fp-kq +mw-cd +kw-vf +xx-qo +xn-at +wt-hm +lm-ps +rq-nl +qr-po +el-es +ps-hh +om-pl +dy-mc +lx-zl +tk-ao +jd-sd +hf-vq +ft-ln +or-dl +ko-bx +pb-dj +uw-il +sc-xv +ko-le +eg-ru +lv-ck +ia-xf +al-pc +si-xw +tr-fk +wq-gw +an-rp +rl-qj +pj-iy +ax-hd +am-rw +wg-er +mt-zb +it-po +al-fc +ra-jr +ec-sc +cc-av +lu-li +we-se +nz-ri +kf-ph +xp-xe +ty-cy +jl-do +ot-hl +ep-um +oi-ha +no-xp +el-eb +nu-sj +qx-mw +wd-wi +ig-sb +so-sa +xt-ey +ks-qt +tw-wk +hi-ub +xw-ba +nc-ra +lb-nw +jn-pb +ud-gx +cu-xv +cu-ka +sa-py +nw-fl +tn-mj +ia-zd +wi-fu +sy-gk +hi-hf +la-as +wi-hu +ki-en +xs-od +ge-gf +wa-ku +ha-kx +yk-qg +jk-rp +zv-zu +kr-al +sb-td +ul-ek +wk-gh +gz-gj +xm-sl +dl-wc +xi-rs +wd-hu +nf-es +hg-kz +nq-hf +tj-os +np-fq +fa-bn +ye-wb +ec-qr +fs-ui +zv-gm +wx-fz +pe-uv +tb-st +ri-jk +dd-bc +eq-uh +ds-ps +bo-os +ij-ra +uh-nk +is-eo +gp-er +yc-sh +vg-se +re-mi +wq-hd +ta-mb +sv-kv +ss-oq +by-yi +or-ig +qp-wk +ak-lj +ph-us +ep-sz +zh-ta +wc-ig +lv-mo +iw-wd +al-mm +fo-ee +fk-xg +vv-vg +yr-gt +mo-zk +zo-ls +bn-bm +oh-jq +gc-gm +bt-wz +fq-xd +ti-xy +mo-vq +hm-fr +vt-mi +pi-dc +gr-go +ei-is +vf-lb +fz-vv +vc-zu +nt-zl +yr-vr +cl-ag +cd-nn +kc-vt +cw-gz +oy-tm +pv-ne +my-qc +pl-tp +kz-uf +yp-ik +ps-xf +ik-pq +xj-ra +lq-rh +lv-gx +rn-ij +fw-mi +nw-hz +hl-rc +ky-hf +qm-fb +jo-ko +zp-lz +wz-ua +bd-ha +fp-su +va-av +bv-pu +lt-bc +va-cc +yy-ot +bj-oi +jl-kx +ac-kb +aq-mr +po-xv +nw-mg +yj-uf +do-oi +zk-hc +vl-ic +oc-pl +xi-hw +tl-on +mo-hc +dm-nn +hm-rm +zs-ed +dl-td +tl-db +rd-xp +ns-or +rg-yv +qu-fb +zu-ql +pj-rt +iq-nm +wz-wx +zi-xk +ib-an +bp-hp +ss-pl +lu-bg +ha-bj +gr-jd +at-ht +iv-ho +ha-lw +sb-qm +sv-ya +ik-xy +cl-zi +zl-rd +nm-aa +ra-vn +rb-fq +ag-wr +pc-jp +ch-px +oy-jp +jk-nz +ki-dc +bl-ed +at-vq +pp-ne +nm-li +wf-of +at-ck +yx-yv +ft-kh +gf-sn +cp-ms +cc-dt +es-eb +xy-yp +dl-sb +ma-kj +bn-hl +fv-tv +tg-ky +jl-di +cq-nk +uc-dc +uw-pc +bj-bd +oj-uk +zc-jn +kh-ay +zd-dw +sj-bu +to-rh +zs-np +dt-da +uy-lj +nn-wb +el-cv +sd-ab +vt-cu +fd-av +xu-hf +sa-na +zs-zw +un-ra +vc-gm +yx-qv +xk-uq +iw-fu +hm-vb +an-jk +et-sq +jf-nm +ky-yc +yp-fx +wx-qf +bh-rh +ax-xz +uf-nk +ae-ki +xv-re +mc-xr +fv-lz +yi-zb +ue-sz +tk-nl +ty-fp +zn-jb +da-cc +gi-wj +hh-ds +sz-uh +bx-kl +pc-yg +is-uk +mx-py +ii-mw +as-fm +fp-gi +ep-kk +cd-na +ko-ab +oa-hw +ic-kn +it-ce +fx-nu +gl-rl +xv-mi +hc-ck +vq-gx +tm-jp +oj-sw +cp-gm +ru-sg +xf-hh +eg-ji +py-qx +bk-pi +sq-xk +bc-up +tw-la +wh-jk +dy-jh +fx-bu +bc-rs +kl-fp +vo-ac +cs-nf +xh-yn +pj-la +kb-bb +nj-vj +zk-ht +nt-jf +jh-ty +qx-ii +sf-wu +sr-zu +lu-aa +et-xz +ob-qo +ee-id +jn-dj +bm-fb +lo-rs +xj-yx +dp-vx +wx-mo +tm-kr +zu-gc +vw-tv +db-eh +eo-ei +qg-ag +bp-id +xp-sv +hb-wa +vd-oq +zu-ey +to-rl +ah-hm +jl-hh +zp-st +qp-oj +bu-xy +ga-fn +kz-tl +yj-eh +we-fz +xp-xa +kx-lw +wx-vg +gc-cp +wa-pc +xm-bh +gh-iy +sj-hs +ba-jk +pt-ca +cj-ih +ah-gp +fd-qf +bu-nu +oo-kt +fp-cy +ma-km +lu-nm +mx-ye +do-bd +ig-fa +qp-tw +no-zl +ey-ql +fl-vl +hm-yr +xg-kn +qb-jn +fk-yy +lf-ql +bb-wi +om-bo +gq-ms +dc-hj +rb-pe +ag-ew +jp-yg +tx-bv +hg-db +nk-yj +wk-iy +xa-zl +er-oo +dk-bo +dm-mx +wh-mf +ei-mc +xo-pl +hh-qq +og-sl +ix-xs +jj-fo +xa-sv +pf-kc +ak-bk +zq-vd +bk-uc +jb-oi +sj-ti +rm-bz +kr-so +ie-wq +ww-zp +ir-ef +ub-xu +lv-ud +ow-sd +kr-rf +ra-rn +so-fc +qb-zc +ll-qt +hc-at +yt-ho +gd-sj +ga-er +fv-gk +qa-kq +xg-vl +gt-en +wa-xs +ac-ma +yj-kz +uo-od +jw-ha +jk-ji +li-rm +zq-pl +wc-qm +iw-vo +iq-rm +ij-jr +fw-cu +td-mr +el-ks +pu-fu +fu-km +gf-mt +df-fy +my-xx +yz-hw +sm-ph +cj-rt +jv-kl +oy-pc +su-jh +fn-lk +gd-hs +pf-ts +rd-yn +hj-pi +tw-ul +gk-lz +wg-lk +aw-ym +zw-ng +yp-pq +gc-ms +qv-fq +ae-dc +lq-gl +vw-tb +ac-km +zk-oi +br-xv +av-br +og-rh +uo-ix +nz-pa +gf-te +yk-ag +iv-on +si-tx +ye-mw +ru-wt +gk-st +la-qp +qp-gh +oa-xi +vj-da +cq-db +bu-pq +mt-te +vj-dt +sn-by +ik-hs +ww-ef +zp-fv +zt-nu +kx-bj +lo-xi +hd-yy +yo-nc +xk-qg +wv-ps +wf-bq +qb-qc +jd-xe +tn-vr +wq-rc +vx-fp +rg-am +qc-xx +og-pt +df-ud +ec-ce +zj-us +gt-sg +ow-kl +hp-np +wa-uo +kc-pb +pp-dt +pl-tj +bd-kx +hf-yc +bx-le +sl-gg +cv-si +qo-my +le-xe +jl-jw +lf-cw +iy-cj +dl-qu +hj-ak +dk-pl +zw-sr +ym-ku +de-yy +jw-di +es-ll +kb-hu +yi-te +oq-zq +ig-td +zn-if +bb-ac +ns-qu +tl-eh +iv-kz +rl-ca +fa-dl +yr-vb +qc-pb +ud-ck +lv-vq +zd-lx +wp-tr +ne-cc +ls-ao +gx-ck +gz-od +jf-wy +ek-cj +wu-rs +wi-ac +na-mw +wj-ja +ws-qg +xt-ms +zh-ga +pc-rf +lg-ik +oj-dy +tp-zq +gs-ds +vr-hm +un-jr +kz-nk +cq-tl +ga-wg +kn-fl +xt-sr +eh-on +mm-yg +gr-jo +ze-jn +hl-gw +wh-eg +yk-ew +or-fa +xx-nj +if-do +mo-ud +ln-ao +zk-ud +jk-ib +do-zn +eb-tx +jd-kl +rn-nc +dx-nd +hj-lh +zs-bp +or-yg +kx-zn +vt-xv +un-ij +uf-yt +zb-qx +yk-xk +go-ow +al-so +lx-kv +ah-gt +im-zl +rc-ax +bj-jb +pi-uy +qq-xf +ym-cw +ww-gk +im-xh +hl-tr +ef-gk +gg-rl +of-yo +be-yo +st-fv +gp-zh +zj-sz +bp-jj +wd-km +zm-we +nk-hg +dw-df +bv-cs +ra-ez +ga-lk +ub-dx +xs-hb +ik-ti +ik-gd +wd-jq +nr-ak +bh-sl +cs-pu +vj-ne +ua-we +rq-ln +rn-wf +py-ii +bd-jl +ag-et +up-wu +qb-pb +bk-if +gr-jv +et-xk +ob-kc +ri-ji +am-ie +kb-jq +ge-al +dj-zc +bs-ht +lq-gx +ub-ky +sb-ns +sh-nq +uw-kr +hz-oj +ib-gm +fc-pc +ix-ym +dk-oq +av-dt +sw-is +fc-kn +po-ec +nr-bk +ch-rq +ya-xa +hd-dj +xe-sd +oi-jl +kn-vf +hu-iw +ub-hf +aa-ny +ts-wz +xw-ji +cu-ce +sg-vr +qf-vv +fy-ps +ok-of +wb-uz +jo-go +ns-ig +wu-qh +ze-my +zx-oj +rc-vz +nd-hi +lk-zh +ga-oo +nw-vf +tl-uf +uq-ws +tv-lz +tj-dk +la-gh +xn-lv +zn-oi +is-in +or-fb +hg-iq +td-wc +bd-lw +sf-bc +yi-lg +ec-xv +ac-wd +aw-wa +kr-mm +ek-ih +xp-yn +xp-lx +wk-rt +zp-gk +oh-kb +px-ln +hw-sf +iq-bg +bu-zt +wc-sb +ck-ht +bz-iq +gw-yy +gj-ku +yp-gd +ls-nl +gx-zk +gs-df +mf-xw +xf-lm +so-tm +ey-gq +el-ww +kw-lb +wb-py +bb-fu +nl-ch +de-fk +nf-cp +il-pc +wg-mb +or-wc +te-ie +tj-jv +wx-we +ir-lz +hz-de +my-kc +qv-yv +nt-bz +te-ix +rw-by +so-jp +ki-ak +qf-zm +so-pc +ne-kj +dc-nr +gx-bs +yn-lx +qm-dm +yn-kv +vf-ic +xv-qr +tb-ab +el-si +gz-md +tw-pj +xx-kc +qt-bv +ot-rc +fz-lu +hp-id +un-of +sg-yr +vj-kj +xe-ko +cn-kq +yv-xd +tr-hd +px-nl +qb-dj +ks-si +lo-bc +pf-my +dy-xr +dm-ii +cc-vj +mx-nn +te-mr +kn-kw +vq-ck +mf-ib +xe-go +zs-tf +kj-pv +yp-nu +ep-ph +dj-qo +us-da +eo-zx +gg-rh +xe-bx +jw-bd +na-qx +fk-hd +mx-sa +lz-vw +ey-sr +av-pv +rl-lq +ul-pj +mm-oy +ls-ft +kt-zh +kv-cf +rs-up +wu-hw +hf-tg +rd-sv +kt-wp +pa-rp +hi-ky +jn-ux +se-fz +kj-br +ka-it +ku-hb +js-hw +ba-wh +pc-tm +pt-lq +hh-lm +jm-ch +kx-jw +jg-tg +ag-ti +ss-tp +ye-zx +sj-xy +sj-yp +ax-dk +bh-mx +nn-sa +oc-xo +qx-mx +lf-gm +bb-jq +ei-in +jg-hf +jf-rm +fn-oo +jh-cn +eb-si +rd-kv +hi-yc +sd-jv +ao-zo +ua-ts +cd-mx +dx-nq +zt-lg +ew-wr +xs-ym +de-hd +fr-yr +ba-an +yp-lg +ek-gh +ec-cu +uq-sq +hd-gw +rn-be +jw-lw +bl-ng +lv-ka +pi-nr +ti-nu +no-kv +vw-ef +uw-oo +rb-bu +bg-ux +ef-rq +fs-fl +va-da +vc-cp +dp-qa +fq-rg +nj-cc +jv-le +ge-mt +lh-ht +ph-sz +db-iv +xd-rb +aw-xd +bt-we +ui-st +ot-wq +ql-gq +ux-li +qv-mh +lx-rd +fq-fm +jf-jj +sj-zt +jk-pa +oh-hu +sr-gm +kw-fl +rp-mf +xs-ku +vo-jq +gs-fy +lh-gx +rh-ca +xu-hi +ds-ia +ab-jo +vv-wx +ki-lj +rq-ay +vf-gd +st-ef +un-be +ec-it +ty-wj +ma-iw +de-ax +ts-vg +xy-hs +kl-ab +ms-gm +tb-ef +it-wd +qm-ns +fp-cn +qo-qb +wd-fy +rd-xh +dj-qc +cn-su +yx-jc +ic-mh +kq-ty +ob-qb +cv-nf +zt-fx +ae-nr +dp-cn +sy-tb +ag-rz +zt-gd +qt-nf +yv-fm +ci-bk +sc-ka +ih-wk +er-jx +jw-oi +ku-md +jp-fc +sz-eq +dd-js +di-kx +lg-pq +us-ep +ei-xr +kk-sz +ph-uh +sl-rl +lt-sf +zj-id +dt-ne +fb-sb +wx-ua +ec-re +rb-yv +xg-lb +rt-gw +en-uc +qg-rz +wt-ah +en-dt +ia-ps +gh-ul +od-zi +li-wy +bj-jl +jb-kx +wf-ok +ho-ca +xt-cp +mu-tl +qb-kc +jc-qv +sj-ez +gw-fk +is-dy +zm-vg +gm-gq +cl-rz +ir-vw +jr-vn +bg-cc +tr-ot +sn-lb +wf-vn +kv-xa +xu-tk +bn-sb +ny-nm +si-cs +uz-dm +gg-gl +oo-wg +sz-um +go-kl +fm-uv +mw-uz +xj-qg +kk-ue +cy-kq +qb-ak +gh-ih +dm-wb +wp-mb +vz-ot +fp-jh +lt-qh +ru-gt +zn-bd +rp-ji +ht-mo +pi-lj +qc-pf +ks-bv +ww-cb +ui-ic +hc-bs +ue-kf +bq-is +vx-ps +rf-jp +yt-on +pf-pb +zh-jx +rq-kh +nk-eh +od-wa +gi-vx +no-rd +rg-au +oq-os +gc-xt +wc-qu +ob-pf +ix-cw +ce-qr +cf-it +ku-aw +fb-wc +ln-sz +wg-mg +uy-ae +bx-go +we-qf +ed-eh +vr-mj +ae-eq +vw-st +og-lq +sj-fx +ws-zi +cp-gq +bl-cy +cb-ef +vz-xz +wk-as +dx-tg +ms-ey +ge-rw +ez-of +zk-at +ky-jg +ft-zo +tf-ee +bn-wc +ec-mi +is-hz +wg-ta +wy-sm +ht-xn +cj-pj +if-jl +uc-ak +os-om +yx-xd +zq-dk +zk-bs +qg-et +km-vo +cs-eb +dj-ob +eg-mf +hd-vz +qr-mi +dk-tp +re-qr +kq-jh +mh-kw +uv-rg +ks-on +be-ij +hm-tn +cy-dp +cd-sa +rq-ao +la-ih +fp-qa +cp-zv +yt-nk +wb-fn +nf-ks +gs-ps +cs-ks +xo-tj +nt-ny +ok-ij +jr-nc +dy-zx +ok-be +bo-xo +qa-jh +ta-fn +dy-ku +zs-fo +ak-en +bl-jj +sq-ag +ik-zt +ec-ka +eh-kz +ca-og +zk-xn +tx-qt +zu-gq +ss-oc +as-ek +hl-xz +tv-ef +ep-kf +jg-bj +yk-et +tb-lz +cb-zu +qh-rs +rb-au +re-fw +mf-an +nd-ke +jx-wp +wa-gz +os-xo +hg-tl +jq-ma +or-ti +td-ns +lt-lo +jq-km +or-td +ia-df +sa-ye +es-cv +cd-wb +cq-kz +ri-rp +pt-rl +ze-zc +gf-ie +md-wa +ux-bz +cj-la +sq-zi +mr-rw +vc-lf +fd-vj +jv-ow +tx-es +tm-al +fl-xg +pl-vd +kc-zc +ao-kh +au-fq +ae-lj +qj-to +ez-rn +ci-nr +xf-gs +lg-fx +xd-jc +vt-it +ph-yz +wy-bz +tp-os +eb-bv +vn-mm +bv-es +sw-in +jl-ha +mj-wt +sn-ge +ah-ru +ay-tk +fr-ah +kt-mb +ht-hc +vv-zm +nk-ho +vc-xt +eb-hp +gt-tn +ye-py +ke-sh +la-ul +le-ow +es-pu +mu-gt +dy-uk +hu-ac +xr-sw +lq-ca +ya-cf +hg-on +hl-vz +zc-xx +gq-xt +tg-ke +ps-qq +rb-jc +jg-sh +ui-vl +eh-ho +pa-mf +du-vg +og-xm +tw-ek +pj-ek +wp-oo +dy-sw +lz-cb +xz-de +hf-dx +bv-cv +of-nc +iy-as +xr-wr +fc-rf +sy-vw +eq-kk +no-lx +da-ne +is-xr +jj-hp +qt-cs +kw-fs +zl-us +kl-le +pu-qt +dc-lj +yk-cl +jf-li +du-se +rf-tm +tf-bp +ln-ch +ed-ee +wj-cy +ui-vf +gi-cn +uz-cd +gd-nu +oc-tp +yg-uw +dd-hw +jd-le +lf-ey +li-ny +fn-zh +ww-fv +wr-qg +jc-au +aq-gf +sa-qx +gw-rc +ce-fw +tm-mm +te-by +mg-xg +vn-nc +xf-vw +cv-cs +do-di +jv-ab +bx-hw +ot-de +jg-dx +bm-wc +gw-tr +ok-rn +ab-gr +kn-nw +de-gw +zs-id +ce-po +tb-gk +pv-va +lm-qq +nw-ui +nw-mh +xj-jc +hi-tg +gh-pj +wf-ra +mo-bs +am-ge +eg-an +ia-wu +mu-fr +aw-xs +qj-bh +iy-ym +rb-yx +cu-it +uo-ku +ko-tf +uq-cl +lt-dd +xp-cf +zl-kv +aq-am +ey-cp +so-rf +mb-pe +mx-uz +mr-by +rd-im +od-cw +kk-uh +sf-qh +wr-xk +ja-su +ck-bs +vd-xo +ql-ms +qp-ul +jj-id +do-lw +vw-gk +of-rn +qu-bm +qj-ca +kj-cc +na-uz +xw-eg +vr-wt +ib-ri +lu-wy +qa-gi +ok-yo +nc-ez +bc-wu +nu-qh +fd-nj +yy-ax +mt-am +ke-yc +yo-jr +uw-oy +ei-sw +nn-py +lz-rd +nn-na +ga-ta +so-uw +zi-qg +vb-tn +oc-qq +ul-wk +nf-pu +id-tf +mh-vf +bp-ee +xr-bq +tb-ww +sl-gl +ft-px +pf-ze +oy-al +ua-du +lx-xh +yj-hg +kk-ph +ei-ci +gw-xz +wg-jx +qa-cn +oa-rs +nz-mf +ic-mg +zd-gs +rh-pt +ki-ci +av-pp +di-oi +cb-fv +uf-cq +jc-uv +ia-wv +kn-lb +bx-sd +nj-ne +ke-ky +ty-dp +lw-zn +ce-vt +yn-sv +cn-vx +ay-ch +tg-nq +we-wz +ig-dl +on-uf +dl-vl +ic-fs +nd-tp +fq-pe +oj-in +es-lo +tx-ll +ko-gr +ef-fv +ng-np +lu-ny +ia-hh +vj-pp +tv-tb +uy-ci +rg-xj +xf-wv +oc-oq +ux-lu +ef-sy +bh-ca +yo-wf +xe-ab +nl-zo +kq-ja +ez-un +wk-cj +fc-uw +eb-qt +ft-ao +aa-bg +tf-jj +fv-sy +an-ri +ze-xx +kf-wt +qv-rb +qx-dm +wb-sa +tv-ww +wj-kq +pj-wk +ha-zn +cs-el +zq-om +tk-ls +ti-yp +ei-bq +hf-gi +oh-ac +lv-lh +gd-lg +av-bo +ra-yo +zd-fy +bz-li +nr-ki +rw-gf +kb-km +ib-ji +oh-vo +xr-zx +cw-md +nu-xy +nr-hj +ds-dw +os-dk +mo-gx +js-lt +qv-pe +pt-to +jp-al +tf-np +ow-gr +ua-vg +fx-ti +ji-pa +ot-gw +lh-ck +mf-dw +hd-hl +js-wu +am-by +jg-nq +hw-bc +dd-up +zj-kf +um-kf +wf-be +us-kk +ch-wt +od-hb +uq-la +jc-pe +yz-zj +nl-ay +yr-mu +tf-hp +fu-oh +ta-gp +mx-na +fp-ja +fk-ax +wt-sg +tk-xw +uc-ae +rt-ul +xs-uo +rt-gh +pa-ri +jm-zo +ng-fo +jd-jv +dl-ns +xw-rp +hh-wv +uw-jp +fk-ot +gm-ey +xn-ck +yj-tl +jj-ng +nn-mw +re-ub +no-sv +hw-up +mb-gp +rl-bh +ci-uc +xs-cw +wr-uq +ak-ci +zv-yr +hh-zd +ti-lg +vn-be +hm-mu +tj-oq +eg-ba +qq-zd +zm-wz +um-zj +qc-kc +ze-pb +jg-ke +et-wr +jx-gp +kn-ui +qh-dd +ym-md +ue-zj +aq-rw +eq-yz +if-bj +mh-lb +aa-li +fo-tf +sw-zx +yz-um +lz-sy +pt-qj +gc-sr +uy-bk +bn-ig +sh-tg +og-rl +vd-os +pb-xx +dc-en +eh-cq +oc-dk +sm-uh +rg-yx +hf-nd +wt-mu +zs-bl +mx-ii +dd-xi +hl-de +vz-ax +ti-pq +wu-xi +na-dm +jm-ls +ns-bn +if-oi +am-yi +gz-xs +ah-vr +xk-cl +xj-fm +yp-bu +yi-aq +yg-kr +yc-xu +wz-vv +su-lo +mj-fr +qp-iy +mt-by +nj-da +pp-fd +aw-hb +to-lq +kt-lk +gw-ax +zm-wx +zs-ng +vt-ka +sr-lf +uy-uc +fm-rg +is-oj +lw-jl +qp-rt +hi-dx +et-uq +eq-ue +na-tw +wk-ek +aq-te +ji-wh +np-ed +xp-zl +jn-qo +vl-fs +eb-cv +xy-fx +ye-na +ik-fx +mo-lh +ob-ze +xh-xa +mr-ge +pu-ll +jo-xe +ew-cl +bc-ed +nz-kv +fa-qu +bp-fo +iv-cq +er-hb +hc-lh +qq-ds +hm-sg +pv-vj +ij-of +bb-ma +wf-un +an-ul +cq-on +hc-ud +ns-jr +hh-dw +zk-ck +xv-ce +vq-lh +br-pv +xf-ds +xm-pt +eh-iv +td-bn +ow-nn +fl-yk +ui-lb +js-sf +ze-qo +ks-cv +go-jv +il-fc +gt-vr +ie-yi +dw-qq +ob-jn +gx-at +ya-xp +db-ho +qv-fm +an-pa +ja-oh +qf-se +gp-wp +dw-lm +gg-qj +uw-tm +gi-ja +vr-fr +gq-no +lj-nr +fm-rb +va-vj +bq-hz +ck-mo +uc-hj +bz-lu +gq-lf +xu-tg +ci-hj +ya-im +wh-xw +sv-im +zp-tb +cv-ll +jc-fm +ba-rp +cf-no +sm-zj +xj-xd +ha-do +bj-lw +tl-iv +dk-om +xu-dx +vq-hc +dx-yc +sj-lg +uv-jm +yr-ru +wy-nm +mj-ah +du-bt +fs-py +ti-zt +rc-de +at-ud +ed-hp +wa-cw +ax-hl +ua-vv +lw-if +si-bv +oa-po +bg-rm +mg-mh +pv-pp +oj-eo +lo-dd +rq-zo +dt-kj +jb-do +uh-us +xz-yy +ot-xz +du-qf +vn-rn +ii-na +lu-jf +eo-uk +wc-lk +vv-we +nc-be +cb-zp +qm-or +ts-we +og-gg +jo-jd +uh-um +er-kt +sw-hz +ga-mb +cu-re +nu-ik +cl-et +wi-sd +ob-zc +ep-eq +es-xo +ty-cn +yj-db +yt-yj +vt-ec +kz-ho +le-jo +sm-eq +iw-vd +be-jr +av-kj +vb-ru +mx-mw +bz-aa +oj-ei +zs-oq +ae-pi +gc-vc +ep-uh +sq-yk +ll-si +it-mi +hw-qh +fc-tm +xe-kl +gr-xe +mb-er +ep-sm +ks-ll +sq-rz +nd-ky +no-xa +ge-by +di-if +pf-qb +di-ha +id-ng +gh-as +sn-ie +nz-an +du-wx +ms-kq +xh-no +kq-vx +jg-xu +um-vc +wp-fn +xh-xp +hz-zx +vl-mh +ob-xx +xm-ca +ig-fb +lo-js +td-qu +ft-rq +ho-tl +xm-gg +er-fn +at-bs +ia-lm +zl-xh +in-zx +zv-sr +oc-zq +kt-gf +hz-ei +cc-br +wy-ux +ks-es +bm-sb +st-ir +tn-yr +nt-aa +aq-ge +cl-sq +xn-bs +hz-eo +cf-yn +id-fw +yz-ep +bl-tf +an-ji +im-xp +js-rs +sn-mt +pj-ih +qx-nn +ps-zd +oo-zh +jf-bz +zo-px +pu-ks +gi-su +wb-qx +nl-ft +jd-go +kq-dp +hh-gs +zt-pq +el-tx +no-yn +xr-hz +tr-rc +wc-fa +ij-wf +au-yx +lf-gc +vc-ey +ux-jf +zt-xy +xk-ws +ib-ba +vq-ud +uv-qv +cy-jh +aw-gz +ok-un +sh-dx +jh-gi +km-oh +bq-zx +rh-vg +lo-up +ny-pi +yi-gf +wb-mx +ay-ao +vn-ok +qr-vt +sr-cp +tf-zw +yt-tl +il-mm +jn-pf +df-qq +kk-kf +lz-ww +di-zn +kx-do +oa-js +qg-cu +zb-sn +cq-hg +nm-bg +wr-cl +as-pj +xa-cf +el-nf +fz-ts +iy-ih +bz-nm +og-gl +ii-ye +nz-ib +bp-ed +rz-wr +ae-bk +da-av +ao-jm +er-ta +ji-nz +xt-lf +el-bv +zk-lh +ge-ie +vf-mg +hu-ma +qm-qu +kk-jk +sm-yz +fv-ri +fl-mg +ha-tx +px-tk +wh-an +nc-wf +vd-dk +sb-or +im-xa +ir-fv +ka-po +fy-wv +bn-dl +gl-ca +cs-es +jr-of +bz-bg +qp-cj +pv-bs +os-zq +kj-pp +rq-jm +sf-xi +jj-zs +rc-hd +lf-cp +hp-zw +ig-qu +sc-qr +su-cy +sg-ke +ty-qa +dj-xx +fx-hs +ei-zx +fw-xv +rq-ls +rz-xk +rz-aq +ql-ln +ki-bk +mc-hz +xo-oq +zi-ew +mj-vb +uq-ag +br-vj +ue-se +ru-tn +ru-mu +iy-la +bx-gr +bx-jv +gc-ey +bm-ns +ef-lz +ba-ri +hj-ki +tk-jm +zb-mr +cj-gh +ln-ay +mu-ah +xk-ag +ke-xu +zu-lf +cd-qx +da-kj +bm-qm +bk-hj +hc-gx +ud-ht +sy-cb +nk-iv +oo-lk +dy-in +vg-bt +vo-bb +fb-ek +rs-eh +ez-wf +vx-ja +se-zm +mg-ui +yt-eh +qf-wz +ga-sq +in-by +bo-ss +sw-eo +gf-am +hs-bu +wx-bt +sh-hi +kn-mg +yv-au +us-sm +se-bt +ze-qc +ei-dy +on-ho +un-yo +wx-ts +km-bb +sy-st +po-vt +df-lm +kh-jm +bd-oi +da-pp +zv-gc +sn-te +ag-ws +du-vv +fd-br +mj-gt +eg-ri +ba-pa +sm-kk +tb-ir +ir-ph +st-ww +wd-vo +pb-ob +fd-cc +km-wi +bd-jb +tk-ch +yt-ql +qt-si +am-sn +wj-dp +eo-bq +ms-lf +yr-wt +ub-jg +kr-eo +si-pu +tk-rq +ck-fr +sd-ko +ax-tr +sr-vc +sw-yv +ga-wp +ne-av +ru-mj +jv-ko +gi-ty +ih-tw +tv-cb +jb-di +en-uy +hz-uk +rz-yk +ss-vd +hb-uo +ie-by +iq-wy +xk-wb +zo-kh +fw-po +jr-ok +sl-rh +ki-ft +rt-tw +iv-yj +mr-am +wp-ta +hi-nq +du-wz +ak-dc +ub-ke +hs-yp +jd-zn +gs-nq +uy-nr +st-tv +fu-ma +tj-om +zb-gf +uc-ki +rt-ih +dc-uy +zj-ph +un-rn +ym-gj +lt-up +cl-ig +tn-ah +uv-rb +wy-bg +fr-sg +ua-px +rf-il +qm-td +bo-oc +fo-bl +uh-yz +im-yn +rh-qj +ll-bv +fz-vg +zm-fz +zl-cf +ee-im +mw-sa +qq-gs +nl-jm +wv-df +jg-hi +ca-gg +jn-kc +it-xv +bl-bp +zp-ir +pe-xj +ey-zv +ih-ul +zw-fo +yr-mj +vz-gw +ie-mt +ch-ft +tj-tp +kw-xg +um-ue +nd-yc +ny-bg +hu-fu +cf-rd +zb-ge +ts-zm +lq-sl +al-rf +ay-jm +eb-nf +qv-xd +xu-sh +jj-ee +vd-om +fa-bm +lj-ci +ds-fy +sc-it +dd-rs +ec-fw +wx-se +wt-tn +xz-tr +wy-ny +py-uz +ma-kb +se-vv +ki-pi +dc-ci +wq-ax +pl-os +bo-oq +tx-nf +oa-lt +fp-wj +vb-fr +xu-nd +vl-kn +sv-lx +ts-bt +pp-cc +ft-ay +nt-wy +oy-il +lj-uf +sh-ub +uh-kf +lu-iq +ka-qr +bu-gd +zh-mb +sm-kf +oc-os +ne-fd +rm-lu +bk-lj +wq-fx +fc-mm +kn-fs +zq-xo +rw-ih +qm-bn +rh-gl +ae-tg +hl-yy +yg-tm +xu-ky +fl-ui +vc-ql +wp-of +om-ss +yp-zt +ha-jb +qj-lq +sm-um +di-pl +ik-bu +rw-sn +yj-ho +ql-cp +xw-nz +wh-nz +gd-ti +su-vx +en-hj +kz-on +ng-ee +bh-lq +ix-od +rf-oy +ag-zi +mh-fl +fv-tb +od-ym +yv-uv +iw-wi +fr-wt +ir-gk +bt-iv +tp-xo +jk-xw +pl-bo +oq-om +jo-jv +ko-jd +zc-qo +nd-jg +lk-mb +wg-gp +bh-pt +ss-sc +sl-to +xh-kv +no-ya +uv-yx +ae-ak +am-zb +xt-ua +ot-ax +ru-fr +to-xm +qp-ek +lb-mg +xn-gx +xj-fq +jw-bj +nn-ii +eg-pa +nn-uz +zv-ql +by-gf +oa-bc +bt-fz +mr-sn +ns-fb +yy-vz +ms-vc +pe-yx +zu-cp +lo-sf +jx-kt +ht-vq +np-zw +sb-nm +on-db +ok-gj +ij-yo +of-pj +il-jp +nr-og +xd-rg +te-ge +iq-ny +rc-yy +cu-qr +bq-sw +da-pv +pe-au +og-bh +gd-pq +vg-wz +bx-jd +ji-mf +hm-gt +mi-ce +qu-or +fl-vf +cu-po +no-im +uc-nr +cl-ws +ik-sj +ib-pa +cs-ws +lg-hs +qu-sb +xa-kr +tv-zp +va-nj +uk-mc +to-ca +zu-ms +oh-iw +ya-yn +au-yy +pj-qp +eg-jk +xz-fk +ra-ok +qh-js +yg-fc +wg-fn +rz-ew +np-fo +td-bm +wb-ii +ow-jo +ll-eb +jh-vx +wv-dw +cn-ja +go-cv +xn-hc +te-zb +kk-zj +bo-zq +ya-wz +ts-se +di-bj +my-dj +yx-fq +sz-sm +uq-zi +hd-ot +hj-lj +eg-ib +lt-wu +ie-zb +eo-xr +lv-at +bu-ti +bh-gg +yk-ws +lh-xn +yz-kf +dj-pf +fd-va +is-mc +tj-bo +gh-lw +pp-br +fv-vw +wr-ws +tg-yc +pl-oq +jl-zn +wh-ri +iv-uf +dy-bq +bv-dp +kr-oy +kz-db +ac-iw +zl-yn +sl-pt +si-ds +vz-fk +px-jm +rb-xj +ic-lb +gm-xt +gj-hc +un-sq +jr-rn +bq-in +sb-fa +ww-vw +zm-ua +bo-vd +fs-lb +zo-tk +gq-sr +nl-zk +hh-df +bl-hp +kk-um +ms-zv +rh-xm +wj-su +wv-lm +yz-ue +oj-bq +ks-eb +mc-ta +ir-cb +by-aq +we-vg +rq-px +zh-tw +xd-uv +lv-bs +zj-ep +jw-lt +ij-ez +cv-pu \ No newline at end of file diff --git a/day_23/solve_1.ts b/day_23/solve_1.ts new file mode 100644 index 0000000..cf90b7f --- /dev/null +++ b/day_23/solve_1.ts @@ -0,0 +1,44 @@ +export type Interconnected = { + [key: string]: string[] +} + +export async function readData(path: string): Promise { + const data = await Deno.readTextFile(path); + return data.trim().split('\n').reduce((acc, line) => { + const [key, value] = line.split('-'); + const original = acc[key] ?? []; + acc[key] = [...original, value]; + // Add the reverse + const original2 = acc[value] ?? []; + acc[value] = [...original2, key]; + + return acc; + }, {} as Interconnected); +} + +function findConnected3(data: Interconnected, target: string): Set { + const connected = new Set(); + const lst = data[target].toSorted(); + + for (let i = 0; i < lst.length; i++) { + for (let j = i + 1; j < lst.length; j++) { + if (data[lst[i]].includes(lst[j])) { + connected.add([target, lst[i], lst[j]].toSorted().join('-')); + } + } + } + + return connected; +} + +if (import.meta.main) { + const data = await readData('./input.txt'); + let acc = new Set(); + for (const key in data) { + console.log(key, data[key]); + if (!key.startsWith("t")) continue; + const connected = findConnected3(data, key); + acc = acc.union(connected); + } + console.log(acc); +} \ No newline at end of file diff --git a/day_23/solve_2.ts b/day_23/solve_2.ts new file mode 100644 index 0000000..0269745 --- /dev/null +++ b/day_23/solve_2.ts @@ -0,0 +1,53 @@ +import { readData, Interconnected } from "./solve_1.ts"; + +function checkConnected(data: Interconnected, curConnected: Set, target: string): boolean { + // console.log(curConnected, target); + if (curConnected.has(target)) return true; + for (const key of curConnected) { + // console.log(key, data[key], target); + if (!data[key].includes(target)) return false; + } + return true; +} +function findMaxConnected(data: Interconnected, target: string) { + const lst = data[target]; + + let connectedSet = new Set(); + + for (let i = 0; i < lst.length; i++) { + const connected = new Set(); + connected.add(target); + connected.add(lst[i]); + for (let j = i+1; j < lst.length; j++) { + if (checkConnected(data, connected, lst[j])) { + connected.add(lst[j]); + } + } + if (connected.size > connectedSet.size) { + connectedSet = connected; + } + } + return connectedSet; +} + +if (import.meta.main) { + const data = await readData('./input.txt'); + const acc = new Set(); + for (const key in data) { + // console.log(key, data[key]); + const connected = findMaxConnected(data, key); + acc.add([...connected.keys()].toSorted().join("-")); + } + console.log(acc); + + const max = [...acc].map(x => { + const keys = x.split("-"); + return { + length: keys.length, + keys, + } + }).sort((a, b) => b.length - a.length)[0]; + console.log(max); + const password = max.keys.join(","); + console.log(password); +} \ No newline at end of file