diff --git a/README.md b/README.md index 8414056..4d94a50 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ My solutions to [Advent of Code](https://adventofcode.com) puzzles. | 22 | [Sand Slabs](https://adventofcode.com/2023/day/22) | [day22.rs](aoc2023/src/day22.rs) | | 23 | [A Long Walk](https://adventofcode.com/2023/day/23) | [day23.rs](aoc2023/src/day23.rs) | | 24 | [Never Tell Me The ...](https://adventofcode.com/2023/day/24) | [day24.rs](aoc2023/src/day24.rs) | +| 25 | [Snowverload](https://adventofcode.com/2023/day/25) | [day25.rs](aoc2023/src/day25.rs) | @@ -72,6 +73,7 @@ My solutions to [Advent of Code](https://adventofcode.com) puzzles. | 254.8 µs | 41.48 ms | | 101.8 µs | 2.554 ms | | 100.3 µs | 1.486 ms | +| 320.8 µs | 245.7 ms | @@ -101,6 +103,7 @@ My solutions to [Advent of Code](https://adventofcode.com) puzzles. | 252.4 µs | 61.18 ms | | 101.2 µs | 2.5839 s | | 79.73 µs | 2.4001 s | +| 0.000 µs | 0.000 µs | diff --git a/aoc2023/Cargo.toml b/aoc2023/Cargo.toml index 5652e61..283d590 100644 --- a/aoc2023/Cargo.toml +++ b/aoc2023/Cargo.toml @@ -20,8 +20,10 @@ itertools = { version = "0.12" } num = { version = "0.4" } num-integer = { version = "0.1" } pathfinding = { version = "4.4" } +petgraph = { version = "0.6" } rayon = { version = "1.8" } rustc-hash = { version = "1.1" } +rustworkx-core = { version = "0.13" } smallvec = { version = "1.11" } strum = { version = "0.25", features = ["derive"] } z3 = { version = "0.12", optional = true } diff --git a/aoc2023/input/2023/day25.txt b/aoc2023/input/2023/day25.txt new file mode 100644 index 0000000..a4eead0 --- /dev/null +++ b/aoc2023/input/2023/day25.txt @@ -0,0 +1,1249 @@ +fmj: cgz bbd jmx xdz +qfn: vmq ljd rjg vdn +mxs: sll rhj vnk klq +xvp: qnc vxq +kmq: qvz fcr sdx +nns: dzx gxz mgd fmh +xfg: hks nxj trg pmc +snk: kvn cgz +hgb: szk +dzt: fbt fxc htk +nkb: qph qfs +xrk: gfx +rkz: cbv tqs kpq nsh zcg +dzl: cjf lxp tqb +kvn: nmh +bts: brz tsz ljs +bbh: pxq hhm djh msn ddq +nsg: mlr +dqv: lls qvj +rld: cxv vmp +kjv: kkq +jlp: cmg kmv jqz +szp: jvq fln ndd hcb +zvq: rcr +qnp: brs pbg lls +fqn: vbb dcx dgc +khn: hsr flf llk tmm dbd +fjj: tdm cbl qvq +bxf: ddd +qsf: zmr vtz +jbg: cll pqp cjz cgz +ckc: hgs gbk +grg: bcp +xjn: nxl rsl kjv qpm jjf +znx: dbg cpx hjl +xhg: rlv rsq ssn xtn +pqh: vhz jqq +mqk: ddd cpx kmk +nfl: cfq snr mrh +jfj: vzm dcc mpc xbd +mbl: ljd spq qhz rhv +jrb: bcp +ggf: tlj xpr zns pqq +trl: kfb bpf thd bzh +rqq: cfc qmb spb +cgb: jtx +cpm: dxf grr +mnl: rmt tpv rcq +tbh: pmc qkp +kms: zlf vgd vmp +mtg: hcr +qrx: hgp +bjj: ccv cbl +sld: bpn +bkq: dtv nbt vfc smd +mcn: qcj pmj mss gcd +lnj: mrv +qnc: znp +rgj: gxz +jhj: grm dqc fcd +rtp: skl +xct: nqp cnh gml +lhd: dgp +vnc: nzk pmz bdg vff +qmd: tkh +bvq: zns zlh gks xvk +kjh: gmk dzx +dgv: csm qkp sls kkz +srp: jln qxn +lsm: fgb jnd jgs +dmt: mlp +znj: pqn fmh +ntt: pkj hzh +nlh: gpb xbq +nlr: ngz xct zmm zgc qrn +ggh: jjz cqj zpm zlf +kbs: tfs kcd jhq +vbr: jqq +jls: mrj sgj kmk +zsb: skj pqg +tnf: hjg lxs zqp mlr +snc: dcs kqk hsk xpc pmz tnt +xck: btj rlv +bbl: vhl +fvc: ftm zlg +dpd: jjz xck txs hks cgj +zgp: jhj ctv xpl txt +shh: vvn fhq +ltv: thd jlp rst +dhl: kmq zxr ngp dtf hnq +qtx: lcn zsr mvz gsl +zkx: rsr plg ppv zrp +hqv: zzg +qth: fdg bfx ssn +rxg: xzk sdk sxs fxg mvz +xlk: dxf +sxc: vhv jtb gqk ztk shh pns xdz +bfn: mkm lrh qjm xjd +lkm: tlj vch gxz +gqz: cvz nkh sfj tqv pmj +lzj: pgc rmt tjr +skn: vbr +rxb: snk cxz qth +qhv: hcx zvb tlz +lgb: dmn kcz crc htk tqd kcq +vfc: kdh bzj +mxx: qmt fhj pvc btj +ggj: pkj dft +tgp: bgr rtr hrg +krg: qsr jrb pvk slz +bjn: pmv tgp +qpg: cnh vck fmm +txs: xgv +zlv: rdp flb lxk nmc +mdl: hzt sls cqd cln +nck: slz hnt vbt +pgg: lxn lxc sxt +gkc: qrx zjd +kzq: pff mft bpj plg +nkj: smd xkt mrh gnt +mpv: ctv cdh vfk tpv tng +srr: nsf klg mlr fcv lqt +hlp: xxz zsf +cnh: lvj qvx +mjk: ztr rtx vjt +lrk: tqs +jzj: dkx dsj +fbl: jnm cbn jzj qxk +hkc: zvq vhl hqv gch +vgp: lqt zpn xfg klc +csj: dmq hdp ztr +trh: rld jvk +pph: hnm qjm +hpv: bsz qcd jrb hkx +tqf: znk txd kbs tkh +nmp: cgm zns +kzp: klc kpd +rvk: shb fcr tjj +gpb: bds dgp hnm +mzm: jtx ftk +hbf: rdz hgb +qvd: rtx rvk +dtm: cxj sjt zzg cbv +lqp: xdx vvl jkd +fvm: hms cfq zgd fhp gch +cbl: jqz lqt +ztr: ntb +rcj: jvh tlj +kvr: pvk xcz zfb kxs +znk: tdq +lvd: xds lhv jbt pcl +cqd: qvb +qbd: pdp rdj hgn mgd jqn +sgx: tjq jpc +crn: jqq sqz rhv smb +jrq: hzq ffq szb fdg +qrr: qpm gns vfc vvx sgt +kck: nxl zbm brz +fch: cmg csf +jjh: nmt kjf djk xdb dfv +lgp: nvn ttr dqs +rgf: kqx +hkp: ndd pqh qnp dsf tgn +jmz: jvm tqq kvq fpm +xfk: zmv gtb qdh hrg +fxg: kfb rhj +gkg: dzx +cjg: ztk +xqq: dlv slb rgh +dzj: gss gxz +qzb: lhz czb dsf +qmb: fcr lcz +bjl: trt gcq +mll: bfp qqx +vfz: tfz xdx lhc +zsj: mgc rpf +grz: mrj llk mss qkc +lrv: zxt hqv xjd vhd +cds: dsh kpb jbt pnd xxh +gtr: gng hps qmd jln +rjg: kmk qbt +xkj: jlf +npk: pcm bjn hsr +qvn: bpn zvq cpm +vjt: pnk +tkc: znt jnl brz +kvj: xbq jns bvg pbg +qfg: ktv fvn +nlj: hxx hxs tvg jzr +svl: dsz vbf +hbk: cqh sqz ksg +bhk: psp xzk kkp ndj +tvg: shm mnl dbr pbm +qff: frf zfk +qvb: svz +rfm: gfx nxb kbn +qnm: mll mmt qcj nmc mfh hnz xbl +vln: nbf pgf vhg ztz bpm zxd qpb +ngp: zbs zbm +gzj: tbq gbg +glx: xzc szc +tck: hqb nts +bxt: vdk gml +xtp: phj +hjs: prr trg +fzm: rgf cnh +fvs: vmp srp pcc jbc +xxz: dgp dtf +tnc: jbt chk rcj xgq pgm nsm +hpj: bjl pks nsf rjn +sqd: qzk pjn +vvl: czb +jhz: sgp lvj qpg cnh +jgq: fph gtj qsj +jvk: jzq ktp rld pjr +cqk: cgm thd qkz +cmz: kgt pqp lnj rzb +bgr: fhc +kcd: kkm dzx +qqx: ltf gdh +bpr: fhq +tkt: dxm bdr xpd hxx +vqf: cgb kjk lgl szc svz +gpc: qzc sqz zmv +mmn: fhp +dxn: qsf +pfn: xcz vdx dpl pqn +fqg: fzm smm qks lff +xjq: pxq glx rjd +hms: zvp bmd hrg +cxf: fcv xpr +mvx: nfl rdh bgr gzg +klq: zdl +gkn: xzc fbt fxc +cjf: fcr sfj +xxh: jtv dzj zvl +skr: trg zdl +tdx: jqn bsz flt dxv +mnn: lpm btj shh +jkb: sxs +dzc: fds sqt kkh vnn +hph: csm tdq xsn +lkj: rtr mll zsn dxm +dqs: xxg fxl +ggx: ncz jmq +blj: zgx zgv svl xbl +plm: tkc bbt pkx qxk +smf: kmv xgv qmt smm +csx: gxc bjd mkn fdg pgd hqs +xcs: spl lgs jhm kvn +qvj: zbx +dcc: sqd grr +qxk: gct +cvn: tzf gbr sjr jdk tpv +cdl: pjn xqg kjv +fkg: dmq hfg drn znp +hns: ltf xxz +thx: hbd slb jhq bbj kpd +fmm: lxs +pgc: nxb sgx +gjb: bpr gjq xkj +cxh: rkr jvh vbt vzs +nqp: rcz dft rxk cmg mkr +jgz: vdx +zxr: bbl +lzp: xtz bzh hpz rzb +qbn: pnm xds hzh +lhs: kgs gks jqb bsz fph +trs: ftl +clp: fcv tbh rpl lmk +kfc: bzl rpf +vtr: nxj +lxm: tng +jzb: bpr rzb +qdt: jqz vqk ngh +gnq: nbt sjh pkx djb +hxt: jtm bkn znt +pkj: nhl +fbq: ctv +sll: kdl +jnm: jzj cxj +sgt: gsh qkr rtr +nfj: sqr ggj +mkn: thd pxp +dsh: xkk pmc +tng: zqf +ztz: smf nmp tqq jgz +nqf: bmd mlj qkn pmq +dnh: rdb skl +tpm: hzb tqv fxl +cvh: rkk tzk fsq +qpd: pjn dxl +phj: kgt +qkp: dcb +gsl: jln pcl ths +rpl: nhl fdn +knj: tbh prl cqj skk jfd +hcx: tjr jtm vtz +kjf: xnq gnj rpd +dlt: qsf xlk vvl njp +xsn: rvv +lsv: tpv rcr qdh tkg +rjv: jdk jmq mfg +btl: gxh czs znk ssf +dxm: hsf ttr gfj +qvp: pvc ftk jgc zqp +gxm: xbq vmq xvp mkm nbs +vxm: dhk qvb czs +pnb: pxp sjz cfl hvv xzc qxv gmk +spp: ztr +bql: ppb sch +tqs: xdj +xzk: rzq rbv +tsg: mbl nts +bqv: nlx pvk cxz +ztk: fbk +mvq: xqj hfg hcx qhv ppk +qmk: rcz jpz gcz zgs +nlx: kcl nns nln +fbt: ztk kqb +gks: qml kpd +lcr: mhj dfl tqm +xpr: hpk hkq +cnf: xlr bbz +hcf: lhv tmh ndj +vmj: tck xxg gqt gfj gxk +nvn: mnl nbt rpx zbx gqt +lxp: hmt bdr +gbq: gct dsj +ttj: ckh fvk rkr snl rpd +bjq: sxv pqg +zfz: bds sfj grz jpv +kzr: lxn +htg: vzm ccs plx txj +ckh: jtz glx +gxx: nxb dfl pjn bmd +rkk: qpb hsv vkt +vdx: mkl cjd +srd: bgt ddd +kvx: fpt sgp rkn +ccs: xpm lxm jsv vbr fds +tcn: xxl jlp kgs xsc +fdt: kdh +vfn: xdj dxn zmr +csr: cqj +gdp: ttn pkp gns +drm: jmq kjf ctk jls +tzg: kmv gcb kvn +svb: thh rnj pgd mdz +pmd: rpd zfk +dfm: hqb dmq +fpr: ltj hjl rdp +zvz: tqq +dfv: dzk jkd +pqm: cxz klc +mnj: jqq +tzf: qkr bgq +zhq: cln qdt msj dcj +cjl: qzc qst pgg ghc +pft: tpp jfd xvl gnz +xzq: rdh djb dpz rnq xdb +zxd: rxk dzt vtr +fhp: xbq +kfj: tnt +qdd: zns +kdf: hsf pjn gzg +qks: zvl +tqm: lrk spb rnn +cvv: hpk qts +rhl: snk mkr qrj nmp +jqd: blr vtr pjr +mkr: drd thh +fsj: qvx +zbm: xpd qcj +tlj: scz pks +kpb: vdk gcb pxp vdx +xcz: lcn crl hsq +cvt: cln mdd +xmd: dhm vgn dtf qdg +rjd: ndj ckh +hnz: zfk cpm rpx +qxz: hbd dzj zsr tfc +fvh: pqm qxs +lnv: vbf vgn tgp +dqq: jzp npv gdh bgr +qzk: qnc jqs +sqf: hjg +pkx: sgx xpm +mrl: jpz ssn xvn +clc: ddn zfk fvn zcg gnt lsv +mgd: vxs jtz qvq +ncv: rvh shs pgj dgp +htp: dcb +rdj: bbd +bdh: kkq dmq ctk +kql: lgp bbr hxx lkz bql +vnk: nck vkt xds +hbl: nrh pll zvp +fdg: xln +mkm: ffv +njz: skn xdg qnj +qqq: nxl jpc rdp +mnd: ggx qjm tqm +txj: sjh tlz shz +mvv: qvd srd tdj cjf +rhv: zbs bxk flb +ddn: spp +pmq: dxt smd qkj +stv: dln +zqh: rpf xdx vxq fqb +sdl: xnj mft jvn hbd +kdc: pxl lsj zpx dcj cvv +vff: nmh +jfd: lcv jbk +vbf: cqh +plj: pcm tqp cnf +bpd: tvp rln xfg vdx +qpm: ggc bgt +mfh: rjv zqx tdj +brn: zgx +tmh: vff +bvn: bpr hsq zlg +bfj: nlh ntr dsz cdl gnt +hpz: rst pvb +cps: tcx ppv sqf zsb +dcs: kqx bjd +mkj: gch plj +ttt: bds dvc gcd xzv +src: hgs chz rjl dnf +dlh: lkm qjj gng pss +xzv: hjl vvl mfg +vnd: rjn kpj nkb hvc hpj +tqp: rdz +mbk: zvl bsp qsr +gbr: mnd dmt ljd +tkg: bbr +jvh: jgs zvz +rfn: fpf hbf mtj cvl frh plm fvn +msn: zjd hxg +vdk: nns bjq +tnl: srd ntr pmv +hzb: gdh tfz ltj +lls: dmq +vqc: dqv rsl qfx ddn +lxs: pst +jqs: xqg brs bgt +sjt: cxk kmk hmt +mcg: pks nkk crl +ksh: kbs djh smm dqp xjf dhk hbd +rdb: tpj zvb sxt +dhm: brn +hsm: fpf vqc chz ctk +hfx: jzq xft hzq bxt mkr +xdq: jsv dxl jkl +vfk: vbf gzf +gxc: mzm +pll: hcn +cdh: gfn rxq sch ckc +gcq: cgz +gcb: xsn +thh: htp rzq +csf: pqg ftl +smd: lxm +dkc: pmj tlz +xpd: mlp fhc +zrr: cjt xlx +zvl: dlv djh bmm tfs +nsx: pkd hkg xrv bbk dzj +tgm: kgd jgq gfs zpm +ltj: mvh rdh zgx +nxj: tcz gss +gzq: qfg kfc xdx pgj ksp +cxk: xbd +jhp: kpd lvd +jvq: hqb qhz xrk tck +jjs: nbs lvm bds nkh pnk dbr +jvm: drd fdn jlp +fxl: bgq +qcd: jzq snf mql +bfr: rzb hgp +knb: nfb ztr +vmg: zpx jfl kqb xtp +gfn: dpz shb pkx +mss: rxq +qtc: bgp xzf zsf btv xvp +cgj: qvx znk +fxk: lmk hvv gmk pqn +pjr: cjd +pcl: trs +jsq: ckc nvq jnh mnj +lnr: bjd lqt skr qdd +hgm: zfg tlz sfj +bbk: pxl csx +rnb: gbk njp vfz lqp +lxn: lxc +vps: smb mrj htp vcx cvp +ldg: kbc kbf czs tkf zvz +fpv: qph tbn crc pzk lts vpr +tzv: bdr +dcj: bmm +qnj: rvh zfg +znh: bhf tbq zlf +sgp: sjz skr +mnm: pcl kfm pvb xkk qsr +ngz: scz hsq rfq +crc: gkl msn +fcd: sch hnq +slj: nsg pss jbg dsg +bbd: kdl +drc: fbp hcc pmj sld +rtr: gbq +lpx: pbm nmc +qzn: rzg tfz mjk pph ntb +rxq: lcp +jvg: ztr ddd qkk fhc +rnq: ktv fcd gch +qbv: nsf fdg nsx +flt: kkz cgj cvv sll qth +zth: rfq +zpx: jhq kgt +qxs: snf tdq gkg pxj +bmd: ljd +tqn: tcx chk tcz +cxz: vpr +zlc: rmt mrt fcd +ngb: jkl +lfk: tcz hzt ssn dcs ftk +prr: kgd qpg qrx +dtv: qvn fds cpm +hjc: tzk lkr jnd +jns: tmd dfv cfq mjg +ftz: spq dxt dtf hkc rqk +qkj: fxl bxf dxl +qdg: tgn dgp dxn +xbl: lvz gnj +rgh: csm bbj rxk +qfs: vjn +gjc: dcj sqf lts crl cll +tqk: pnm nsg +zsn: xjb smz cdl +qrn: jvm hxg jzb +qpb: fjj txs +hhh: dzc bdh ndd plx qzk +dsz: xqc +fvk: slz zzb +bfx: gcq +bbt: tlz mlp +gng: zdl +qmx: hhk qnc jgj jng dgc nfq +djb: hbf frh +xzm: dpl fjs rzv lhb snp +dkt: sjr qkk qzb +jnl: lhz +kqr: smb ngp pmq rvj +jzp: hgm vpv xlk +fhq: plg +sjh: nmt vhz +bfq: zmv +rzg: qhc jbd dlk rdz +bpf: jgc qkp +hkg: kgp zjv csr xnj +hsf: crh +zrz: tgn xpm mpc +nmx: rbv tbq bxt hph +sdx: sjr +frz: pqq hgp ftl lts rgf +pdp: zjd qrx +xlr: cfc +zgd: mrj bxk cqh xdx +xdb: lhz +cvz: lcp +xqj: rdb hcn tzv fdt +kcq: blr zdl xsn xtz +cdz: prs hns tvg jnl +bgp: ndd fpf dhm +lmk: djz ndj +rlv: qfs +tpx: pnd xzc vhv kvl +gqk: pnm cxf +dzz: jgs vck rdj +jgj: gjr mdb zgj +rfp: rtp crh dbg zxt nkj +rnj: npg xgv jtx tpp +gpv: klm nmh zjd +zkj: lhd kjv sgj +vnn: jnl nvx +fvx: gvv mpc bbl bxf qfg +jjg: qxl cqc tqn +sdk: dqp kfj +fxh: tng gpb +hkq: dnc +xbq: tdj +fvv: dnc jlf +rjl: ntr ksg tkg +zsf: fnl +hht: qkk vnn rcr cxk bxk +gkl: fmh jbk xgv +smz: gns zxr pcm +mxh: jtz fjs zzd +kxs: xdz sxs +rcz: zdr +zbn: zlc pbl cpm +nqv: dsf +hdv: lxn xqc +ncz: mlj crh +xgq: fvc fdn qrj xrv bfx +plp: nkl mtt bbk +qzd: jgs rfq cjg +tgn: lrk +sjz: tvt tnx +fht: tsz dkx qfq +szb: jfb +kcz: pxp vck crl jss +txb: vzm njz xhl kck +ght: jhq cxv +rdp: ngb +xxg: fnl +dmh: rkr dqp snf +mrs: ctv ndd bkf mnj +pgk: tkg jqs dzl +zpm: hkq mtz cjz +kkh: dgc gvv +tcd: bqv fcv klq +hqs: jtb xlx +hcb: fcd qxk hlp djb +nkq: psl cqc jbc lhs +kfm: pzk fph +qnk: dfm cnf dsf frf +rfd: tqb jng kpq hlp slq tzf +rqm: vlt zdh bqv +nfr: mmn +pmv: bfq vfq vhl +svz: kkz +mdv: lpc pdp szc +pcr: zxd xxd xds bzh +ssn: tqq +mql: rhj +djk: ljd nvx tdj sdx +lhb: tpp +fhj: fdg ccv xds +slz: fmm +jtm: ctv gfx vrr +cgx: vxs qlm dlv kfj +hkx: qxs kzp mnh tbh +gdc: pvb gtj gvz sls +jhm: cfl jtz cjt +dxv: tvd rkg hzq ptf +sqh: cll hsq nrn jhk +bpj: bmm +fps: bgq fxl +xcd: jqz gvz bfx tcd pkd psp +jkd: fds mrt crh +tsz: rtp +lmc: zzd ths dmn +bpm: xzc pfx pdp +mhq: hsr jmm kbn +pxj: snp pgd +kkm: jjz +cln: gzj +czb: lvz +vdf: ngh bvn xlh xvh +fpm: jkb dmh +hxl: rcz fpm +fnf: xlr tpm dqc cvz cbz +ngv: mrh sjt tpl +hcd: vpr dqj ntt gnz spl +cxp: fvv +pkl: drb lvj pmz +tbn: rlv nsg trh +pbl: lxk hmt ncz +jkq: hqb tgp mlj +cvl: tsg lgj sld +qkc: cvz prs +hrq: drd dcb fsq zsb +ffv: zqx vpv bbr +lch: ftj str lcv qxn +xxd: ntt qts klg +tcx: szb +fzd: cbl bfr jrb +jxb: rjn pvb qmd mrl +dzv: qfx flb hxh xxb +jvc: kjh dmn zvz bsp +nbs: qkr +gml: dsh +qfx: plj qkc +nmm: qjm bbr +vzk: mrv nln cqd tqd xtz htp tvt +xls: rjd pgd snf jnn +bhp: mxh hgn nkl smm +nts: mvh +zdh: gpk +nkl: xgv nxj +rst: rzq +dxc: xvl fzm hgp fbt +kjz: dsg grg znj +qsj: lgl +tbf: bmd rpx lxm +kbf: pcl +ksp: dxt hnq +ppr: pcm nkd hqv +njj: nvx frh fht lzj +jfl: nxv nbf kvq +fpq: pgk gvv jrk qhc +czs: lgl +kts: gjq vkt klc cgb gml +nnk: sdx zvq nfb +zfp: dsz xkt qpm mqk +bqx: zsn lcr rps +mkf: jqs nlh dkt qnj mdb +hsk: tmh trg kvl +chs: skl chz gvb +sgj: hdp +pqp: gng qxl jfb +qsk: xzx dxf spb gnt +qtv: tkf bnf tcx jqd pzk hkq +bvg: mfg rqq hdv +hvs: jpz +jnh: frf dcc qvj +xhl: pbm gvb sjr +xvh: cgm vst +lpm: hps cqk gbv +sxh: cqj rqm hzt jqb qcd jpz +cll: xkj zth +jvb: shs jns brn npv +mnh: bpf gkg fgb +ltz: xpm vkg fdt bfp +qph: kvq +pxl: pmc vkt vqk +rzv: dzn tkh vvn +dvh: zcs qhz rvh +tvm: njb lhz mvh +qsl: nfj tvp ffq +trt: bbj +cbz: zfk fvn qhz +jgd: kpd hhm lhv kvx +skk: blr jss zpx tcz qsr +mvz: djz tzg kcl +rvj: rlr +mmt: bzl hls +vhh: dcb cxp csm +jng: qkc xzq pbm +gzf: txt dmt pdg +hcc: rnn cjf szk +tbx: cdl lhd tlz ctk +xkk: bcp gpk fmm +psl: tqd trs tnt +xxl: jfb qvq zzb fdq +plk: mss zvb dvh +vpv: dsj +mtq: gtj hxl jvm fjj lnj +plx: nxb jnh zgj +nxl: vrr tpj +lrh: ntr smt jqs +qlm: fsj kkm gcb gkc +qbt: knf dzk +jvz: sxs fph tnt nln +bbz: bds slq ltj vfq +kkp: zzb szb rzb +mxq: jlf rbv +frd: lhb xmf gpk dft +fql: bzl knb tjq llk +dkx: gch +pzj: mdd qmd zrr +bdv: rdz nqv tqb mnj +dzk: zbs jnl +msj: xtt mtz nzk +pjg: fbk znh chk vjn +ftl: fmm +rkr: lqt +vgf: dhm lhc lcz dnh brz rvg qqx +pgd: rzb +kpj: vst fch bgz +rsr: mkl nzk zpn hxg +jmm: qvj vqz bbz +slq: qzc pmv +gxh: pmz xtp +rsq: psp vdx +llk: tlz +rkg: bjd hjg +tfs: qmd szb vck +zlh: szc +cqz: vfq +lgs: gpk gxc mbk +xbd: nrh cpx +gbv: rzq +xft: jkb lpc rgj +xnj: kjk zjd +pxx: knb lxc vjt +ndj: gtj +vzm: jnl czb +znt: vhz fbq fps +vvz: lzj nmt cxk jbd +pkp: qmb +flq: pst hxl zth skk +trc: qbv dnc dmh hjg +fbp: hns vjt xbq +nsc: jgz fgb zlh +jgc: zjd +qjm: hmt +tjr: pgc lxp +fln: mmn kkh +tdj: snr +krs: kzr txt lxp hls +fqb: tqp dfm rvj +vhd: qzc dkx +dnd: fqn gfs dpd qpc +rln: ccv djz jtx +gqt: ljd ttq +brq: mbr sfd tpm qkv +gtb: xdq gjr ppr +zqk: hfg fqb nmt tzv +smb: xxb njb +fpf: kkq +jzr: jpc +spq: bfq hnq +bfs: thf qkp slb jhp +dpl: snp +svk: qsj snl dqp +blk: mdv zrr zjv kvl fbk +pks: bpj +ddd: brz bgq +mjg: vbr brz +xdz: ght gvz +rlr: sch rcr +pxh: nsm mxq +xvq: jxb gxz sxv jqd +lff: hcr +hkr: gnj vgn psr mkj +mtf: bsp lff tzg fvh +hnt: kqx vhv bbd +hvc: phj pxq rfq +bzj: pbg smt tqv +tdl: zkj njb nrh tqs +hhm: vff +dzn: slb jfb +plh: hnm zmv xcr +mzc: kzr jtm dgc kdf +gfs: dcb +zlf: cgb fld mxq +kpq: xns vhl dxn +qts: zdr +ddq: xlx kqb qmt jmx +lvm: njp xcr qqx +rtt: znk pff ngz +zcg: zzg +grr: fbq +vmq: ghc +kbx: sxv cqk fhd trt +gvb: tjq chm +mzt: lqp gpc xfx vps +xpk: pkl nrn rpl bjq +rkq: znx rjg xzq vjt +vvn: fhq hgn bhf +mtt: rkr spl pjr +jtb: jqb +hcq: csj ddh dkb +shs: sqd cqz +jdk: hdp +vbb: gkl dcs jgq +gjq: nxv dlv +xpl: sbt vgn bpn +fjd: lhd cnf mkj mdb +xzc: lcv kfj +ltf: hls dpz +nrn: sqr rlv qts +bdg: lvj nbf tmh +nfb: rdz zzg +jvn: tpp xdz +ksq: ktp pvk ssk jpz vjn +lks: vvx vdn bxf rdh cvp nrh +gnz: cjt +fgv: pmv mfg jvs kkq +bpb: mkn zdr mql grg +zrp: kfb pns dmh +zkc: lhs zpx gxh stv +nzk: kfm tmh +czc: trh skj ktj gbg +qst: jsv hrg hns +ddh: ppb llj +xjb: ckc nfr txt +frn: xvk qsr npg pdf +jgf: zmm shx plg gqk +gzg: cqz xzx +djl: gml spl jnd qml +rnn: vtz +xtz: vqk +dbg: mlj rnn sqz +ffq: csr lvj +rps: sld ntb +crb: nmm smt sbt +pkd: cjd pjr +lxk: zsf bkn +scd: jln xqq cvt lhv +hps: fsj hvs +shx: cxp gcz +rtx: lcz +cvp: pll qkr +xtt: qxv cjg cxp fdq +bqt: djz jqn qvb mtg +rqk: gch pmd jnm +pnd: jgc rvv +vxq: knf ktv xnq +bxk: xdg +hcn: gjr +pqk: xkj sls lgs tpp +nfq: zfg jkl +xlh: dln dnc mdd +nsm: rbv +qpc: kkp rzb kfb fvk +fdn: qxv +zfb: zzb mkl kkz tdm +nmd: rxb xjq bhf csr +cjz: hcf zjv ftk +ppk: skn kfc fbq +xzx: bfq +tpj: rfm gcd +tfc: rst lgl +zgc: csx xlx gpv +pdg: nmt zvb +ppv: nmh +chz: jpv spb +dgc: xlr +nkd: hnq kzr xrk zqx +pqn: jqb +ths: xgv klm +xqv: jkz xkh qsf zgj gnj nfl +vld: hhk qzn bkf lrm +gmc: snf gkl hpk tfs +pnk: vkg grr +dlk: xrk xqg +xnm: svb sqf lkr hjs scz +jjf: qkk pkp xnq +xkt: jsv psj cvp +cfl: mrv pvc gcz +thf: nkb jnd fgb +ftm: scz cgz fcv +lrm: hxx +ccv: kgt +qml: pnb pxh +qjl: zrr nqp sqr trs +bmc: tvt tqk rgj tgm +vhz: szk +ssk: npg fdq ndj +qjb: cmg tqk btj hjs +zhm: ddd fht drn gxk +njp: zsj dxt cqh pph +xjd: zcg nbs ddh rps +jpv: mrh dlm +shb: ggc +mdd: cgz +tpl: ssd +chk: tqd +ptr: mbr dtv dnf rvk xdj +jbd: sfj fnl +rck: pmd tsz ckc rvh +txz: zgv xzf prs +rcd: plh gdh dsj +vdn: dhl dbc knf +pcf: pll nkh gvv qff +shm: dxf +lpc: vst +zzd: ngh qts fvv +dhk: kvq qvq +xrv: bbj +npv: nmc gbk +pgf: znj hkg ght +pgm: vmp snp pff hpk thk +lpg: jzr nmm tnl qmb +vrr: dlm +kgp: jzq xtp +tnq: rvv qbn cvt znk +cqc: qkz kcd kbf bjj +pkf: rdj grq rjd tqk +lqc: klg vxm xfg pqm +mqv: bgt rcq hdv fvn +jcb: tqp txz tpl rcr +xvk: kxs cln +bmm: xkk +fmc: zlg csf trg ckh mft +xmf: nbf nhl +rvg: lpx pqh +grm: ttr rpd +prl: lkr xhp rxk +hxj: ppv djh ddq vch pkl zjv zlh +qgn: bgz tlj rsq hqs xln +nnn: bsp kjz jvm gfs +jfp: nbt zqf vvz ndd khn +rmz: fvv gzj hbd +pss: gnz fxk kdl fvh fxg +ggc: drn +dvc: ggc tmm gfx +ftj: pxj srp cjg +qxl: hzh ngh bzh +xxb: qpd nvq gxk +znn: nmd tnq smf gkn +qkn: fhp +sqr: zqp cxv +cgt: pft chq glt svz +flf: zqf nfq +hsr: rvg +hsv: dcs pst bbd +gbk: ltf +ktj: nfj vqk mzm +cxj: ngb vtz +btv: zxt zgd zbx +xzf: hsf sjr ngb +gxk: tzv +mlp: fxl +spt: gsh vhd tqv tsg lgp +vqz: pbg nnk +qsg: rvh bds xcr +pbg: lrk gct lxc +sgg: ddn qzb nvx psj +nvq: cqz +jlt: lpc jlf +ztf: plk qcl zvp gfj +ktp: jnd hpz +tnx: hzq +sqz: cfq +fhd: xvl rbv +xxc: qst clz ztj fps +qrj: vst xrv +jnn: qfs cbl bcp +psp: thd +lzm: ccv mcg kjk zhq hjc +nkk: qfs jbc +sqt: dbd dfl +zfg: xrk +dxl: mvh +pqq: rgf cbl +lgj: cfc zmv ttq +lcv: rbv +dvf: qkn xcr vqz sjr knb +mlz: rtx smz fpr cbv ttr +pht: kkm vbt hzh hgn +kbc: dmn nmp thf +pcc: tkh xln +xfx: jpc dqc qvz pdg zmr +hnd: jkl gsh ggc cvz +pfm: tnx qpc vxs dzz +grb: cqk glt fsq stv +bhr: xgq fmh pdp kgp mql +jhb: nkk bpj fjs fsj cjt +lkz: tmm hdp +jrk: ssd hjl dmt +hxs: vrr tqs njb +sxv: kpd +xvn: jjz zth chk +vvx: pkp +bsz: frn +llr: jng hms jzr gjr hcq +drb: vbz rgj +xhp: phj nhl jbt zrr +kqb: qvx +pff: bhf bfr +znf: zgx tdl xbd hsr vkg hxt +hhk: xxg llj +qdh: ksg gqt snr +xjf: tvt mlr xln tvp +dbc: mrt sqt xdg +zmj: klm lgs nsf xvh +ptf: pxq vpr tdm +crp: jzb grq bsg jvn hjg +svr: zgj tqb fxh xxb +qjj: jvh rzq fch hxg +jtv: hhm kjk jnn +vzs: kqb qzd pnm +rmt: vfn +zcs: zvb zbs +psr: ksg rfm lkj +cbt: jpz lff clp plp +xdj: znp +bsg: fvc lts +jkz: npk vvx frf fqb +cfc: lcp +qxn: dln grq sll +cfm: xck jgz lpm qks +kqk: hcr zpn jbk nck +pns: fxc fph +vgn: mlj shz +jss: fgb jlt +vgd: dzn jqz qxv jhp +xkh: tfz mgc xpd +vbz: cjd gbg hvs +sbt: kdh kzr dnf +zmm: mtg jqd +glt: jkb jqz +xtn: tvp vhh vst rld +mpc: tjq qbt +nfn: vjt kmk mmt xdb +kfb: pvc klg pcc +mdb: hfg qvz +fpt: hzh +qcx: fzd hmg gss bbk lxs +tjj: qcj xnq vfq +lhc: xns nqv +ttn: mkm vxq +rsl: nfb tmd hcn rpx nts +prc: prs shm fhp crb flf +zvp: qvz +bkf: skl fhc spp xqc +smt: xns +klc: zdh +jbq: mrs xqc mhq hnd +lkr: kqx +mtj: zcs nvq bbz +rvh: vbr +brs: cpx ghc +gzs: jjg svk kgd pcc fhd qdd +sfd: svl lsk bbl +gsh: znp +xsc: jlt cxf bsg +tvd: kcl fjs +tnn: qxs tnq pvc cxp +bnf: lsj jnn gkc +rjn: nhl jnd +blr: zdh +dft: pzj +ssf: gss bjj nxv +mdz: jqn gcq mft +jsx: zxr qsg ttq dkc +tzk: pkj tqf qph +gff: kkm rmz stv cxv +zsr: jbk ssk +gvn: nfr qqq jdk nvx vfk tjq +qzg: pxh gbv zfb nxv kms +lcn: snf htp +gfj: snr xdg +fsq: kbf +hdq: gct gvv jkq qvd +cbn: qrr gdp zcg vmj +kmk: qfg +ljs: rjl flf spp +jhk: nsc zgs lmc drd +cnr: qsl kbx gjb jtv +qbq: hsr zgv jvs rvg +xpc: txs gvz gzj +jlm: znx ghc kdf +vkg: ksp +fld: vch vbt srr npg +cjp: kdh rcd mjg +lgd: psl cvh lmk szb +fzp: lnv ndd hcc zrz +cxv: xgv +rnk: lgj dbc vhd +vhg: smm fpt nsm +dlm: hls hgb +pzb: gbk dsj qhc znt +dcx: nln cjt qks +zgs: zlg qmt +cgm: skj +bkn: tdj lcz cbv +bdr: bfp dfl +vcx: lpx vkg xdq +vvj: jns shb lvz nkh dbr +llj: zqx dqc dlm +gmk: dln skj +pjq: rnk zxh dpz hgb bqx +kbb: nfr lkz vmq xzx +prj: tfc hcr tvd klm trt pqg +plt: tkf xls zpx qmt +rlj: pst jhk vmg rkg +bzm: dnf dsj lrm gns ktv +dkb: dbd vpv znp +lbk: rlr tbf tvm ltz +pdf: mtg cqd bfx +rtv: pzk xlx vch npg +ppb: fnl kkh +vbt: nbf +mhj: xns dgp rcq +hmg: hzt vxs pcc +fxc: tdm +tmd: xbd chm +bzl: xqg drn +mkl: qsj +hxh: tdj grm lrm +kcb: gcd rcd bts cjp +dmv: gkg pxl sdk hks +qkz: hcf mrv +dvv: cvz ctk jsv szk +txd: jtb shx nrn +sns: dcx pxh ltv dpl +mtz: hvs hvv grq +mbr: rtp ssd +qlg: cjg nkl qdd kjh fpt cvv +hlx: zbn rpf dnh jlm +lsk: hbl nqv bfp +pgj: nxb ttq +xds: kmv +xvl: kzp vqf +ftg: lxc skn chm mvh +zxh: pxx bjn lls hbk psj +tbq: hcr gbv tnx +hcm: ggx bql gbq nsh +bnh: mgc pcm sfd nlj zgv +vsf: kbn gzf frh tdj +mfn: xzx bpn knf qpd +ztj: dkc sgj flb +shz: hrg zsj +jbc: pvb +bgz: gcq vtr +vlt: bjl dsg cln drb +str: rdj hhm +dsg: gbg +vpr: fbk +kgs: gxc bxt nsg +jmx: scz rcj +ssd: rcq dxl +htk: hvv lhb +tdq: mft +sxt: pmj zmr +hgs: ntb tpl +nmb: kcl rcz zvl bfx +dqj: dzj nzk zqp +qfq: pcm zqf mrj +jcq: fxh chs qkn nmt +tkf: xkj +chm: jmq +vjn: gss +mrt: rdz zfk +fdq: rvv +fxr: shm qrr ttn lcp kbn +zbx: dlk spb +zpn: kdl +xqc: qcj +jqn: kvl +pfx: hks vhv dhk trt +rpx: hnm +qcl: brn vfq vtz +thk: kqx mnn rtt +qhc: spb +clz: ftz vzm spt +kgd: nxj +rvm: bbt zmv qvz dqs ngv +dbr: chz +zdr: fdq +psj: sfj +jvs: tsz rvj fdt +snl: ggj gcz +rbr: zxt tmm mmn jpv +nsf: pst +nhl: lnj grg +qkv: vbf qsg fln dqv qff +nsh: cpm xlk psj +chq: fmm dhk qmd +rkn: skj lsm str klq xmf qsj +lsj: rhj xtz +lvz: rxq +dbd: mgc diff --git a/aoc2023/src/day25.rs b/aoc2023/src/day25.rs new file mode 100644 index 0000000..f7b68db --- /dev/null +++ b/aoc2023/src/day25.rs @@ -0,0 +1,61 @@ +use aoc_runner_derive::{aoc, aoc_generator}; + +#[aoc_generator(day25)] +fn parse(input: &str) -> petgraph::Graph { + let mut graph = petgraph::Graph::default(); + let mut nodes = std::collections::HashMap::new(); + input.lines().for_each(|line| { + let (origin_node, target_nodes) = line.split_once(':').unwrap(); + let origin_node = nodes + .entry(origin_node) + .or_insert_with(|| graph.add_node(origin_node.to_owned())) + .to_owned(); + target_nodes.split_whitespace().for_each(|node| { + let node = nodes + .entry(node) + .or_insert_with(|| graph.add_node(node.to_owned())) + .to_owned(); + graph.add_edge(node, origin_node, ()); + }); + }); + graph +} + +#[aoc(day25, part1)] +fn part1(input: &petgraph::Graph) -> usize { + let min_cut_res: Result<_, ()> = + rustworkx_core::connectivity::stoer_wagner_min_cut(&input, |_| Ok(1)); + let (min_cut, partition) = min_cut_res.unwrap().unwrap(); + assert_eq!(min_cut, 3); + + (input.node_count() - partition.len()) * partition.len() +} + +// Note: Day 25 does not have a part 2 + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn part1_example() { + const SAMPLE: &str = indoc! {" + jqt: rhn xhk nvd + rsh: frs pzl lsr + xhk: hfx + cmg: qnr nvd lhk bvb + rhn: xhk bvb hfx + bvb: xhk hfx + pzl: lsr hfx nvd + qnr: nvd + ntq: jqt hfx bvb xhk + nvd: lhk + lsr: lhk + rzs: qnr cmg lsr rsh + frs: qnr lhk lsr + "}; + + assert_eq!(part1(&parse(SAMPLE)), 54); + } +} diff --git a/aoc2023/src/lib.rs b/aoc2023/src/lib.rs index e726bb4..15d7d62 100644 --- a/aoc2023/src/lib.rs +++ b/aoc2023/src/lib.rs @@ -24,5 +24,6 @@ pub mod day21; pub mod day22; pub mod day23; pub mod day24; +pub mod day25; aoc_runner_derive::aoc_lib! { year = 2023 }