From 0d652660f1ba2c6d3fd593774e8a9f0c19a4d16c Mon Sep 17 00:00:00 2001 From: xuu Date: Wed, 20 Nov 2024 09:07:01 -0700 Subject: [PATCH] chore: add day25 part 1 --- aoc2023/day25/example.txt | 13 + aoc2023/day25/input.txt | 1261 ++++++++++++++++++++++++++++++++++++ aoc2023/day25/main.go | 63 ++ aoc2023/day25/main_test.go | 41 ++ grids.go | 4 +- 5 files changed, 1380 insertions(+), 2 deletions(-) create mode 100644 aoc2023/day25/example.txt create mode 100644 aoc2023/day25/input.txt create mode 100644 aoc2023/day25/main.go create mode 100644 aoc2023/day25/main_test.go diff --git a/aoc2023/day25/example.txt b/aoc2023/day25/example.txt new file mode 100644 index 0000000..f5bdcc2 --- /dev/null +++ b/aoc2023/day25/example.txt @@ -0,0 +1,13 @@ +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 \ No newline at end of file diff --git a/aoc2023/day25/input.txt b/aoc2023/day25/input.txt new file mode 100644 index 0000000..c202334 --- /dev/null +++ b/aoc2023/day25/input.txt @@ -0,0 +1,1261 @@ +kln: zrp +hcp: xhl mrh zhh +gzk: nqx stx mln nsr tpm ddq +pql: vsl ltr cnc shq fjm vpg +hjp: mft vkm +xgv: btt +gbm: kjm gvb +lhc: mdq zrd fxc +kng: ssb mln +xlm: lnb +bpr: trh +mbh: nnv lcx xhq +bvs: mmd ltr +bch: rdq ppr pkd +ftm: tjp mqc vxk +jvr: bcd +vtt: znh +sgn: xxm bjj ftc +zbq: cvr +tff: btd pqk +bqh: xrg +lkv: vnp +srq: kkp chx xmp vbm +htj: spt mpn mkc qfx +rbk: jzz +stv: gdp qnx tgt ggb ljt +nvr: dtj xgc +qxd: vnx +mdq: xcm vnx +png: hln cdc pgt kqn +dxm: fhr fks gxv fpr +gsm: vsd +jzn: hpc xht vhn qmp +hcv: nfj gzt rvc +slb: dkz +pfr: lrk dqb +bxl: bjj nmc xrj xmk xhg gqt +kgs: msf fbh rrr hjp drp +jkf: vbm +dgf: bjp lzf vld rmg +jkg: ckk +vlt: lrz zkt +rpc: mhx sxx vkp frz +tft: zdt +gvc: ccl bjj rjb lrv qhh +mmd: xmp +mrb: gxh ggb +zll: rsf tfs +jjj: gzf xvs +mls: cpc vmp +bpm: fzq zzs +fjm: bfh scl rtx +gll: fdx tgk +svs: ltp cgx slb mks +srk: xjd kfp klb gcx +xvq: hbr qzt +gqd: rds ddq sml btm +bqg: lrv lch qgq dgz +bdv: nrd qbv +vnm: rvd +sqr: xrh tqh +zhl: ksm xcl mbd cgv +clj: psz fnj crx hbk +kzj: nxd +pch: ldm jzv +nch: tft bpd ljs +zrp: csd +tpm: vqg hds +kps: bnx +bpz: hqm cbb sss rsf +pps: tkx dcp sqr +zlt: krh +qds: hlm mrt rpk rcj +jjm: dtp djg mgp lps +brh: fbl xpk +nfc: xls kdr ljt jkd +kkj: xph xsf hdf +xsp: lml bgz hln mgk +jfq: qhh vlh mhl qgt +npq: jdl gjd bxf rjb +rxv: zxt sld +dvj: pcg svq crx +lcl: nrn klb zjh gct +ppq: dlj tcq +klk: bzm +czt: pnq +rhv: vnk +clh: qlh rqb +sjb: hvs pbl jgn vsq +tfd: mvc +tbn: xbq +qnv: qzt tkd +tzf: hsn +pbg: tzf mdq vgp rrp +dxn: znh bgd +dln: bjf xqm hmp jld rtm +frz: pnr shd +tgt: tqz +fhf: jkl sgm zct fsl rqx +tzj: qbq zfq bsg +qlp: mxk zgr tcq +nfz: pth cpd jrr cvl +jxz: xbq dvq +mhk: qdm +mlj: fdl pfr +qbp: jpp ssn sff gpf +stq: nnv ptc nrd +tbj: vqh xdn prc xgv bdj +mfx: khj mzl bls xgc +mzm: vbv +gcs: qkd zgv dpd +gmc: gqt gdt mth vnp +srz: sff knr +nln: mmr pdz zzg +qfx: qjb vgc tvk +fln: pkc pxn mhk gcb +vtq: gzt tcf +rpr: csd +xlh: ncl lch qsn jpx +fpm: ltp kqs jbc +dnv: vxb svq ljv trl +jhp: shx sld vjh btp +nxl: pbs +svq: jpp vsd jpx +qlh: nxk fkn msx +rcv: lgv drp gsq nmc +jrr: jqj gsq +tfk: cff frd dfz hnt bvb +dbl: tcq rcs +pdz: mcc +kls: grb vnf txt szv +rfq: gjt rss qcl +zps: qsk hjq grb qzd +ktq: hlt vsk +zqt: xbd srj +jvk: cxx +xsf: qcp +kbc: xrk hmm vhn +fbr: lls kjc vnp +qvm: gbm bkf bxf shc +bcs: frd +tvm: sjz +nfj: hlx +cqp: nxl pkv +vkj: mfv sjh qxk zkm +dzn: xzc gcs tfd crx +mgv: bch bmd dnp sfb +jpd: dxv +dnp: hcv qss lpt +htq: vxt klr mth gzn +kzs: ktj vsz hct +mdv: rzp mnl lml ptc +vxp: rqm frk grh rkm crg +xxm: hjz vnm +rcf: xmp +xfg: vbv ksm svr +sdb: mnt hsn qbf ccp +tst: rvb +kmr: bqh rcm +msv: lpl rvl hkf +zrr: trr mrh kdz +sfk: gmc jxl pjt xlh +brx: jhp jhm qbh rfv +bqp: cpt hbv qss bpd hjj +hjg: lrz mjj qvn +qgc: bzn njk drg +zzn: hjj dgl kgc +gcb: xhq lfg bjr +jgn: xhl ddz nqq +ljs: kbk mjh +nsr: btd ntb hcd mhk +fqg: bsg rvc bqp gsc +jgx: drp kjg zsk tbn +ttq: lkv njs nfk +zch: kms jpd vtq srb +tkk: svr ctp hln +rnf: rdq lkv kjc xgf lkd +kqx: pcg vvk +smd: nbf ntt +gqb: ljv kmd pzn rnq +bkk: xgr vqg jpn dtn +sch: jzv vlh +fcj: grs vkj cdd rzp fxc +ljj: jfm pnr xcl dtp +rpk: txz vnf pln +txm: tcp +trq: dtr lsr hkn xjh +btd: kvx +fml: hjz drv rvb bvp +gpq: mxt gcx bvd qls ttl nvj +fbf: crh +vlq: qdf nvn tnf fxg vjc qpk btt +hdd: zzs npd zck +dmm: qtp bhj +pkd: rcm +dcb: jdx bxb skp rsg +jpc: fnh ccl pzc +qbf: ddq +fks: sgj xqc kbn +dps: kjg tfd kgc tkf +jjb: gvd +hrb: bzs tbs tht srb +mdn: nsc tlb ckg pmj +gxv: jjj kzk bdq +jqj: pbs +pbx: qkl +djj: tbn tmb +bsf: lhd +cvz: klr hvr vrg hkf +hjb: zfc hff +rqr: vnx glf qls +rrr: shc rcx +gqm: dzq gkn qbj +fsm: bhd xmm fqj tvm +cgx: bjf lqh nhl qxn qcl +fpr: fdb blm lkp ldb +cdc: fcv +vhh: bld fgg dxn bhj +zhz: fcp vcs bld +hxp: gvd crg +bsh: lpt frh xvj +pkc: xcl ghr +pff: nnv nvj nnn npm jld +jzv: gvd +lgv: xvs xsv pcg +bzh: dkz jcg xgl tcp hnh rzz +jft: kkj ntj jjj sbq dgz +jcz: ljv +bjr: shq mqj +gmt: xsf fht jms +qph: kps hch +jms: ckk +jnz: gzt fdv cqp fkm +fqx: fdx ssb +ndp: pqk btm qcc hfp lps +rbf: rpp jmp jxz mrt gkk +tmq: rqx stq txm fzv +hpc: bfk +bpb: rdq xhg +czv: hrs kvl kdc crk cgc +jkv: ztc fxs rhk dlj +vln: smh mpt +nnn: ktq hrs ksm dpm +zdf: zlf rfv +zzt: qfn mpm fnz bpf +qjs: gct njm lmz shq +bbg: qvn +tqz: qvn +jjc: zhd fmj ccr vkm +fdl: hqm kxt sck +lbj: gkk frd zkn lll +tzm: hcv scx xdn xfd +zzd: hct cdx +vrh: rnd nts lzk tcf +vvq: kkp ztl jfg sml +ngg: jvk cbm +qjj: fts +cvn: rnq ckm sjz +rmq: bzm rvb hbh grx +fgz: thg zbx vcr nhl +mts: hct +mlp: njj shx btm +mvm: fqs cvr hrs +cpg: qsc hkp bgz +zjr: pqk +jfs: tks qvn +fjc: bfh rbb vcs dzf mcc +bbt: rqb ngt pll +vvd: zjr bcd dtj vxl +rlk: vhn mks njm nmh +brn: hhz hrs +hbb: cxx djz jvj +ggr: qbj +crk: pdz +grx: xqg +btm: xgl +vnf: tks +zgb: pzc pjn bnx cxp +hzs: bhd fnz tsn +lpl: xrg kdr +mzl: xdf +ksf: jvj +ksl: nkl xmf +jmp: rjb qgv +tbs: prc +cbx: tkd bxb +vss: qgd xck zbx nsd rhv +kjj: vzf +xlx: kkn lrh kjj ctk qgm +hqm: hjc xhv +mkc: xdf ztl lmv +txz: lvd msv +vsq: qls pgt rrn +gjt: bbz +lzc: jms jpf ftm +ksg: dtj +nqx: mbd nvr xxh +hxq: tvj rmp gdt mjx +pgj: glf cxx rcf +zxf: nvp ktj jxx +glf: fqs +qjb: ctp kbp +kfd: gvs +npr: vsj +lqn: njj +dtr: rds fzv crk +bzn: npd zcr +ndd: lsp qcc +jpp: vgl bpb +kgr: jpn jch vtf njj +rrm: pgt sgt dsr kzj +khs: mqc pht hlm qcp +xrc: skp nnl lsp gfx +fsn: gct gll +drj: zdt llm bnd +cbb: cgc zgr +zzm: vtt sbc mqm zrd +czn: vnx xgl hcs +xhv: bbz hps +vsd: bpf qgv +bfh: zct +vmp: phd +lms: bfk rsg hhv +rcx: rkq +xpg: gsl hbv kjm tjp +fqv: dkz +qfj: lqn +pgz: jxr tvm +nlv: nkl vbv lzf +xfd: cpt mvs +jcv: mls rcj xmk vxk +jbc: kcd rrp smz djg +lvm: jvv +qlz: ptc +ngs: dlt vgt tql +qgq: dsh +kzt: dps +lfk: sxd ltm nsk +vcr: rht lps hlj qlp +dcp: cdd gll vgc bld +ptq: xpn dfz qcp rvl +djp: btt gzn xlh fbr npd +dbp: szx qvc +dsm: hjq jrt pdj +ltb: dbp +vhp: crk qtt +jbq: vln xlm sht +dzq: mts khj hdz vsk +qhc: zct brn jkk zdf snd +bjz: zzt gxk xps srj +msg: grs +nhv: hpc vzp znh shd bcd bsf +drv: fvc gjd +gln: bqh ljt +lcp: fzn lvz xph xrg jqj +sss: lqh +kvl: lcb +hbf: kdz jvr xjd zlf snd kqs +kbn: vkm qvc fzn +cfh: xrj xmm +xcj: hxs pkv bzn +frk: jlt sxd xlm +zpt: jpp xvs +vtg: dgq jnt zlt mqj jxb +mrt: fjl mjh +qrg: btq bst pln chc hjq +xmf: jtp +zhd: xsf scx xlk fjt hng +dkg: hmc mts plz kcz +grl: jjb pzd gsc +spm: bnx smh qdc vnm +rdr: qxn dmm rrk tfs +hpn: vqg zfc ntb mlp rrk hds +mpm: dgl sgn +fjl: pkd xsv +qbj: dnm bgd bjr gtt +gdc: dbn mjh tzd +mjb: qvb ccl bnx jbp +tht: pdj +rqm: kjm +rxt: llq fgp ckz +vcm: rmp bzs mrd jbq +ntj: xsf bxq +fmj: tmb tcf +rpm: kln ndp mzl +fhr: gls njz +vlh: jqk prc gxk +qdk: gtg vpg fjc dtp tql +mpg: hcf clp cls +shr: nqq mnl qjb jlb +vqp: mpt tft gln tmp +ffn: ztc lbl gbg kfp +pmj: kbc cbb xmp +drk: mts tqh vtt qkl +vkp: ppq hcd +krk: glf vgp jzn +qnh: hbz sht hpf xlm +gtp: hbn qhz +pqs: lml ctp zxt smd +gmz: nch fnz zlb prc +gdt: fnv tkf +mrd: lmb blm pbs kgc szn +nxt: tcx nkl +lkd: hjj frh mrb +jfm: qhz ctp +ltm: qpv +nqq: fgp +fnh: xcf +khx: sms xpk bbk +vfp: cpk zrj qfj xxh vtt +jxs: xzd nsk +rcm: gvd +hpf: phd mhr hcv nqz +vqg: bfk vjh +bnt: qvb dgl rxk rsm +qnx: dpq qpv +ppf: pmz znh rxt ghl +lgc: dck fkn jdx slb +jkc: rnd xfn dfz srz +fdb: fqq txm qzd hjp +dtn: kxt ltp +drg: jnv +cpc: grh +clm: kcz vrj kxt +pxn: krh bvs +rpp: hnt xmk rjs +rvd: tzd zkn +tqh: bcd pnq +qgd: rbb cnb rtg hhv hrg +rdj: drj fvc vzf bbg +bvd: zxt mcc +dsh: bkf +gtl: mpp nbb mjj +rrv: zkm mnl rrp lkj +dvs: rpk sch qgv +nrv: hdd +zlv: pnc rng hdd cfh +xnb: btp rtg lbm +mfh: fnh dvs jvv lnc +dtp: jvk +zzq: bhd pcb dpd clp +lcx: jtp +qpk: gdm +jcg: vnk +fgr: rrv nmh lnr +zxb: lkj ggj qnl csn +gqt: ckk +sms: qxv fnz +gtm: ggr jjm kqn hnh ltq +dmp: rlk bjp cpg nxr +gjd: jxr +bsj: tjx kng jth tvk +smb: gqt tvm lnb +dkp: fml hch qpv jdz +pzd: hcf cfl gbm +nnq: bbq blm tbs tbn +rtx: jfm +shc: smh +rtn: lbl dmr rlp +dgq: qjj rsg +tgp: nqq gzr dxn +xrh: cxx +hqg: crq rrf +bgf: jnt xjh dgv krk +tcx: jnf gvs +drp: ltb bmh +lvp: kqx lll jms vzf mxr rmp +ckg: lqn nkl hcs +xlf: nvn nzk vpx zck +dpq: kjj vdf rrf +qvh: qxf qtl htt bld +pcg: bxq +jgr: gsv hbn kqn rpr +gbg: jkv fts mln +jdq: mvr jjr lcp +rks: jdn pfd jnf +cls: cgr kmr rjs +bjl: zkq rrk vgc +nvn: cgr pkd +hvs: kcz rds +jpn: kfc jkf +tcq: dsr +mks: dml plz +szn: jcm +vrj: czt sjh +ggp: sbn qmg bpm xfq +xxh: vbm gtt +bkr: cbm rpr lfv +mqg: bvs dxl qjj +mhl: mpm gcr rjs +kvd: spq cmh tsn +czp: flj rcb qbm rkq +tjx: qcl gct hct +bct: hhv lrp smx btm +qbx: vqg pph lmz nlv +ljt: bbg +gvb: gxk xph +pbz: kjm zsf nzk ppr +tdp: cmh jqp gdc +dpr: hff jvj bpr +zxc: nzk +njm: rxz jlb +npm: kln zkm +qgt: xpg mvc lpb vlt +mrh: jnf +hfr: hch mft +vxs: sjz fvl mpt dkk +jzl: fht flj klr +srs: xgv xgf vlt jpb +gkk: dhg vqq +cxp: lnb +nfk: xls brh +lmh: nsc zfz gtt bxj ggr +rtg: tcp +xck: ssv +jxb: rlp mgk kbp +crq: tkf qph nsk +kdc: vcb phj lcb +hmc: tzf mvm +tsl: hdv hpb qnv dsr sxx +gjc: tsn npr rnk vmp pbz +lnr: mxt qbh mvg +rqp: pkc nvj ppg +rxz: ksg bgd +mln: ktj +kpn: xfg pxn vtf +pht: bbq qss +xmm: tzd +pgl: vmj dvq +fhd: fvc hjg gcd tqj rqm fkm +jps: hdf hbv bnd ncl +chx: hcd qhz +hxf: cxx vdx rmg lml +pxd: fgp jvx sml czn +kmd: sfv ltb tgn +rmg: kvx ltr +dqn: gdm rsm tbs rvb +bzs: gmh qpk +zgv: kjm vpl kdr +htc: ntb hps xhs czt +kcz: dlj +dqg: rvl dbp vdf hlm +rff: vln qbq qbm +dpm: xck +lmf: qdf mpt jfp qvn +hbz: jpd zcg pth +jbp: jqk xps dbd bbk +sjc: bbt vtz rjt lcl +nsh: jdq jfs cfl fzn +sgj: fht +hmh: sxb ttl fbt fdx +vdc: vvd srg nrn ngg +dqx: vxs qrg +sgt: zkq jtp +tnf: kxs hbh mdh +xqm: qsp gtg jvr +rzz: nrd +tmb: mdp jzv +xps: zsk +xcf: sgj +ssn: lvz nvs grx +vxb: cjk pcb vxt +svj: qcc nxd lnt +sbq: vcq hbk hcv +ptg: njs btq sgj +pbr: pbs fvc pkv ncl +phj: hds mkg +jkl: ssv gcx zlf +dtv: rbk fqq nrv gzf dsk lvp +dck: sss qxd +lpt: gft +frl: rxd hdv kzs rhk +pnm: gqm gbg ksl xjx slb pkn +ntb: tcn +mth: vcq zjg sxc +qbv: fcp +nxd: bbz +xqh: gsq +dtk: pgz htd jxz +fzq: jfp +hmp: zzd mqm +qxk: nnv +rcb: jxr llm hnt +sxc: kqx +qlb: lmv zlt rtm gkn +gct: kzj +bzv: dbl pgt xnb +xmk: szx pkd +cnb: qmp +vgc: hbr +dcv: zsk cpc xbq +gtr: dtd ggr mlj shq +tfz: nxt mxt sgt scl xjg +dss: fgp lmz mmx fxc ghl +rtk: szx xlm lpb +nmh: pmz tql +cgc: mhk +zrm: hjz cvn xzd +qmk: ddz rtm +ffk: mnt btm bpv +szz: bbk flj zdz +khn: jjr hlm +fsl: lqh +jdz: dpd njk qpv +rss: kvx hdv mnt +pcb: flj jcm tjp dsh sst +fjr: tkx lhd mbh zhh +kbb: vqh pmh lvz srj +sqp: gtt jlm vxl fvz +zxn: tht jjq vgl +rnk: jzl xls gxh +xqc: kjm +ccr: kkn nbh hfr +rrk: rhv +jtb: rmh jvk phh nds +rjl: nvs jrr dcv dqx mdp +mpf: ckm jjb dqk +zsb: ngg fqv hjc rcf +kkn: tjp fxn qrr +clf: txg zqt bbq +dqk: tcf tvj +mvl: xhq ngs fvz clh czj +thg: hjn lmv hbn +nnl: mzm qhz +zmt: sgm ndd rrn vcb +bvb: phg mdp chz +vts: cxf qdf lls zcr bdq htr +fnv: tst mbx bxq +ghl: sld +hlj: hln lcx lmv +rhj: dnm jxx ngt +hdz: tkx cvr +jmd: lzk hjz ltb +dhc: xfd lvd sff +scx: kkt vsj mqc jlt +ctk: pbs jjq +klb: rzp mqm +plz: fts dmm +sts: xvj xmj czz kmr zrm +pph: kdz zrp zjt +bgx: qbm gpf tjt nzk +qxn: cbm qdm +rht: gtp mqg jnt +fng: hml xqc jpf nfm qsn +mpb: xgh ctk xrg +rqb: ntt hkn ltr +bzf: hhv tvk sss +fcp: zfc +xhq: tlb +jcm: kjm zsk +rxk: pkj +jts: sml smz bpv +mmt: ftc qvf dgl +rvl: tqz fqq +xgr: nxk mmx jhm +vsl: rxv sbc rks +lfg: qnq trr kfd kdz +kkt: txg xgk +qzd: hbv +mjx: qgq cgr +pmh: zdt gsm +hth: vnk +nvp: hqm sck qmp +qdc: tcf xcf +tzd: pjn +cnc: ksm bls sxx +qrq: jfm mgk ppg +npz: zxn lqx snc khk sht +txt: mbx xgf qxv +czz: pgl +gfn: gsc vsj xph pdj +cxf: lnm krn +kbh: qdm ghr ssb mlj +mmg: phh zln ktt sfz +bzz: gls kzt vpl jrt rbf +xrk: qbv lrk cvr +hxs: mnb kps +fdv: xsv qgq +khz: bst kpv hxq dbn +sct: tjt sxd zkn lzk +mfv: vdx jqn kkp rcs +tfl: hhs lvz lvm khs +ngt: msg +bbk: qrr +bhn: jvj png nxt zlt +vpg: qsc +nlx: djj hpt tzj xqh dhc +tjf: bcs hhs cfh +ppr: qvz tmp +hvl: vxl tff +nhl: qrq ppg pnr dpr +knr: qvz +jhr: bgd hhv mmr +xvs: vmj +gsv: kqn zll tlb gtp +qxf: fpm hxf ppg +ssg: hpf kvd mls lzc tqt +msx: csd xmf +hqn: fng xgf ntj hvr +zlb: dpq bpf +nrd: bpv +xsb: stq +gft: srj xbq +kgh: fsn dzf jmt qxk fbf +dsd: grx bxf hch +srx: glf ggj +hdv: pcr +kms: fvc +fzn: bmh +vlf: mqm bvs shx zct +cdm: jnz crq vxk nlc +scm: hhv qlz zll tff +tgk: jlb +hds: qmp +blm: htr kbk bsg +jxl: mvs +vcb: zfc hsx +cgq: xht rpm kxt +jvv: pln gzt +rng: rrf vnp +qvz: brh +xhm: hxs lkp jnv khx +rzp: xvq +tsx: lnr lfv vcs hkp +grb: gdp cjp jmd +xjx: hjb gpq bqq +hpt: drv rxk +vpl: lvz vnm lnm +hng: crg lkv xpn zbb +zxr: xpk qkd mjs xxc +jkk: lmv dmr rtg rpg +fxg: fxn dbp jjr +jvx: pjx xcm srx +dgz: jfp qgq spq +ggv: mzl mvb mnt +jmt: hpc gcx czj +bvv: htd ckk tfd +nds: lps trh +mrg: zct jfg +mjs: pch rvd hnd +jqt: nbb ccr tpq zzs +rkf: zjh vbv mqx kzj +htt: hfp nvj bsf +vzp: ksg fqv +nkz: jpf lvz bnq +snq: cmh zdz bpf +jhm: mpn +svr: zhz cnt +rhk: xck rpg +cpt: mnb +lkh: rdr xfg nln dxl +qss: nqz zcg +bzm: tft jdl gsq +gxh: kbk +lrq: tpq xfn rtk fhr +dvl: nbh zlq hxp tks sjz +mpp: bvp kzk rvl +sld: trh +lqx: flk bvp pht +hsx: czj fgp gjt +cqh: kjc pjb ckm zxr tkf rvc tbn +hrg: sgm zrp rcf +tvq: zsk hlm bpm kjj +hlm: vjc +chz: zbb dcv lzk +lrv: xmj vtq bzs jlt +pnp: pth tzd +mmx: kfc +hnt: tmb knr +lbq: trr cgq nbf mbd kpn +sxb: gzr fgr lms +cgv: fqs hmc jkl vhn +clt: gzn dqk grh qnx ljs bbg +dlt: xhs xsb rsf +rcj: qdf qrr +jkd: lvd hxp njs +xgc: zfz +pbc: pmz nrn kqn fjr +crx: jlt +nhb: xrh mgp lbl hps +qtp: xmf +mql: fkn snd sjh rqp lrp +lsk: lkp rbf hbz lnb +qsc: jnf +zlq: sct jdl +ghr: gtg +lbl: pmz nrn +mxh: zlq dvj lvm xxc hlk +rcs: qls +kjg: vdf xlk +lkp: mbx +sfz: vcb mmd bsf +djq: nfk czz csm +mvg: kqs +gkn: hvl mqp qmx +tkx: xhv +snc: lvv vlt ncl +mdh: cdh prn fvl +zdd: fxn gfb fmj ckk +ckz: hds rsf zhh +vxt: cpt gmh kms +tqj: cfj +xgq: nrv txg +nvj: hmp +fnj: xcf bqh +qkd: tgn qpk +vgf: ltm jpn pzn sxd mnb +lnm: dbd qgm +ddz: vnk jfg gzr +cpk: qjj fsl +mhx: jfg bxj +kpv: tst qxv npd vrc cgr +ztc: lxd pbl +xlc: srz fpg zck dbn dhg cls +jch: xvq msg +mqr: pdj cqp klk +hnn: gvb pgg sxn zdz +dpd: pkd +ntv: dck vvd mvg vcb rzz +qml: mmd zhg tkk zkq +mdd: mzm ndd lnt +mjj: xmj +jsn: bmh kbn prz +krj: tff hmm +cjp: jzz +xzd: hch +kdv: tgt hxq xqc mbx jcz bbg +gcr: gkk gxh npr +jlk: hvv nkz vnm shc +htd: hxp vsj +bxj: qsf xrb +hcf: vgl jnv +tgn: gxk bbq gps qpk +dsk: gsm tht lvz +fqf: tzf hvs xjd +bvg: ltm szz zsf pkv +gmh: vqq +pkj: dsh jfp +tkz: qnv lzf vgc dxl bgz +smh: ljs +fgx: phj hsn xcm mhx +bvp: gxh +vjz: fvp hbh zpt xxm xvj jsn +zss: qnq jch qbf zzd kvl +pjx: mct gsv pkn cbb +zjl: jnf dnm jth +sfl: pjc kkt vvk gmz +chv: rkf mzm qdm djz +vbv: hct +psm: pkc mnt hpc rtn +lpv: sts nmz sfl +hhs: mfc pzc sgj +lxl: mkg jnf pfr jth hcp zzg +jlb: qfj +krn: vrc xrj +szv: njz pjc vnm hlx +zhg: vhp dzf fqs +tjg: vcs hth hln czj hsn +sbn: sfv mpf tdp +ntt: dkz +rvb: btt +hkp: mmr fbf +jgf: zzn qgc gfn rnq +tct: xgl ggs fcp hcd +gjs: qzt xsp hbb vkp +vsh: txg lpt kzt gdc pjn +dxv: ldd lch gmh +gls: jvv vxk gcd +bxf: bnd +kzz: xjh pff bjl ttl +xpn: qxv hnv +mvb: qls tkj pbx +bdq: jjr lnb +cfl: xrg fvl +qhh: ldm xlk +dtx: lkx bpr vnx ssv +rmp: szx +sff: zzs +ngn: mxr clp pnp djr tqt +jbt: rrk htx nbf nlv +xls: vmp +mlq: gps kzt xfd rkm +dxl: bjf +zjg: dbd +jgc: cnb fcv hvl dsr jts +bhj: jvj kln +nts: fvl lpt +ksm: ggj kfp +hjj: qvc +pzn: mft pcb +gps: dpl fjl ldd +njk: jkg sms +vsz: csd vrj pfd czt +zjt: qxk zlf +mvc: qph xfq +jdn: dtj hbr mbd +plm: fbl xhg +mxt: hlt +hmm: khj +xqg: btq bmh +ldm: kzk +ktn: bfh btd rpm +zkt: pch bjj +nfm: fbl qsn jqj lkp +rdh: bxb dlt qdm fgp +qsf: zkq +qfn: qvb ncl zbb pkd +xgk: ljv vmj +vkm: rqm +mvr: kms jpd sht +vlx: xpg bnt skb pln +sxg: bgz bdv vpg +dbj: hcs rxv qlb jth +mft: dkk lll +xmp: hgs +vdx: nnv fsd +ljv: dpl +qbm: nvs +fpg: jpc rng hpt +bkg: cbm tkj gkn bvd +mhf: kkj mqr njs smb +zxt: dnm +hzj: gcx pqk tcx +gpf: bkf gsm +phg: gxk smh +mxr: fvp gzf +lvs: pfd hdz sqt cbx +fgg: ksg +crj: jlt frd xhg +lkx: hlt ffk pnq +qtl: qtp +hjq: tmp gsl +dqf: tgk vgt fqf hlt +jnt: smx tcn +xjg: rzp qlz fzv +rmz: kqs krj zjr nfd +hvv: spq zcg flj +pbl: fqx mgp +ccp: rph krh jhm +jld: lcb lcx +vqj: dgq kln ksl jkf +hgv: vgc qtl rlp qbh zfz tlb lsp mvg zhz +lzk: dbd +nhx: rgj czn bdv cdc +gbr: jkf cdd jhr mkg xhl +rqq: hpt pch rkq msf +qns: zjh nfd hgs +sgx: kjc cxf rrf vmp +sxn: jbp zkt +qmp: jlm mpn +krh: htx +djr: mbx btq gmt +vcc: svj rsg mks tqh +qsn: zbb +cvl: skb lvv +hhz: tcn lqn lhd rhv +gsl: rdq +hgn: bjj bsh jpf dnp rsm +vgl: kps +fxc: mqx tkx vsk ksf +gzn: cff cxp +xct: cvl jcz nsk dqx +bmd: dgl mjj +rjt: hcd jlm lnr +jqp: crj +slg: bnx zcg +jvj: kkp nbf +srg: nxd cnt tfs frz +hbr: lnt +htx: qkl +stx: gbr jbc +vtf: vcs cnb ntb +rvp: prz srb xpk pgl +lrh: dpl szn cmh sms +lkj: zjh ghr xrb +zkm: jtp fbt +mpr: fbf fcv dkz gll +lnc: pgz cff jjb +grs: hps +dgd: jlm qbv vqg zjr +kdz: qkl +gdp: jmp +clp: vlx zlb +qqr: fsm npz xqg zng qvb +flk: qcp fnv pmh +rnd: bxq +rvt: qvf bbq gxk gvb +ljq: bsg tqj kxs +vnb: lsp cgc kfp hth +zrj: zrd svj vhh +fvp: pjn +zls: mmt mbx jqk +zbx: ngg gjt +jqk: chc +hjn: qdm pdz +jmm: rpc txm brn grs +tvl: jjr dkk kzk tks zcr +lbm: qhz gvs cbx +vzv: jcz bmd zxc prc +nsc: zjl +fqj: spq njs xls gdm fbh +zkx: xcm dtn kvl bfk +scg: jth sck ggs mqj +gcd: lvv +sgb: tqt rff lch zrm +zgr: llq tvk +csm: xqc tft lvm +bss: bpm lfk hkf bdj +kfc: qlh +ggs: hcs ppg +lrz: tqj xvj +rsf: xvq +rkp: grb cjp rcx rxk +sst: mnb pnp hfr +bpd: jdl +ztv: pnr xgc ppq jcg xcm +prb: mft clf bch jkg +nsd: lxd hjn vhp +jrt: xsv gzf +xrj: dvq vmj +qsk: txt qph npr +hml: phg nqz khn +xhs: sqp rxz vjh +xdf: mcc fkn +gtg: vxl +bdj: zdt vqd zck +jpx: tjt xqh +sfb: xps nlc lpv nbh +lmd: zdz vqh ggb hbv +hlk: gzn qmg sbr +vgt: mgp mbd +mfs: szn ssn tjf cjk +txg: dkk hlx +lrk: hzj qzt +qmg: bjj qrr czz lvv +vvk: chc mdp +tnj: bvv rkq djj hqg +xsv: nmc +ltp: qdm tvk +bjp: qsc llq +ldb: tvj tsn mls nxl +jdx: qzt qsf +rlm: krj clh pbl qxd +lmg: fvp slg txz vkm +vcq: nrv +qnq: fqx zkm +fxs: smz pkn tfs +xlv: pkn cxx gcb ggj cdx +bst: bnq pbs +vpz: rcv lpl gft sxd +cbm: pnq +qrd: qhz qbh rqx ztl +vqd: qvf zxc +vld: zkq ktq qlh +bqq: vkp fts gqd xsb +djg: vnk vhn +pgg: mrb fkm rnd +bls: jvj +cnt: mkg lqh dmr +sck: vbm +llq: njj +hbk: hdf sgj +mqc: xrj +btp: ntt jvk +dpv: mvb ttl qtp sxg scl +xzc: vqd pbs hbh +gfb: gsl bkf dpl +hvr: sxc rnq fzq +lzg: xgh qdc mjx bcs +cjk: xgv xgq gcd +tms: tjt mvc hnd krn +zrd: zbq +fbl: tqz +djf: cmh zqt fqq vkm +hfp: ngt hdv +nhn: qtl mnl rpr khj rfv +qvf: bjj +nkd: sxn rqm zjg cdh jqp +pxm: qns kcz cgc qlh +mkp: smx jlm bjr rzz +sgm: rcs +vjc: xfq nfj +lrp: htx +ztl: bls tcp +xnq: dml vsz kfd lhc +vzf: bkf +sbc: qbf tpm +lsr: kbp fvz pcr +zfz: sjh +qsp: hjb bzf vqg xrh +crg: dhg +dms: tst khn jnv jjq +lvd: ftc +ppv: mbd zbq rcs zdf stx +phh: gtt hjc lcb +phd: bnd xlk +vbx: mqx xcl kfc tcq +nbb: zsf npq +njz: bpd tmp +vsk: bbz +hvh: spt sxx kng jfg +pjt: cjb cpc cqp +cdd: xhl +fbt: jhm +qbq: gdm dkk +rmh: cdc nxk ksg +pnc: kjg grx cmh +sbr: prz kdr nmc +jzk: rgj msx jlm rqr +rrn: srx qxd +crh: jqn mmr stq +zfq: jxs qrr bnd nqz +vpx: rbf djq zpt +ltq: xsb gbr tgk +dzx: jpx hxq jkd skb +jvd: rds ffn lrp hxf hrg +ssd: drg pkj qgm ckk xqh +csn: zbq vzp nsc +gfx: lfv rfq lcx ksf +qnl: hdz jxx nnv ptc +gvp: mrg qvh dtd +rkm: vnf mhr +kvx: hnh +nbh: jrt dxv +kqm: vqj pff gvp nnl dqb +ksk: dkk mpf cfj gvd +rlp: fsd +mct: chx tvk +dzs: ggv fgg ktn bqq +mxk: jlm bpv +lcj: kcd bzv qsp kxt +zln: rmg pbx mzl +xxc: ljt jkg +cfj: qgv +pjc: rbk fkm +kcd: ghl +tvj: qvc +kxs: xlm rvc +lls: fnh gln +nxk: mqx +pjb: nfz rvl ljt +frh: qgq +xzs: cpk pxn hjc ztl +jqn: lhd bpv +fbc: fgg jdp xrh bkr +zng: ssd bkf nfc dtk +skp: bgd rtx +dhg: bjj +cmb: ptg ftc ldd dsm cfj +kxz: mrh nds rgj rtn +tkj: pgj tqh +xjh: hmm sbc lfv +mpz: zsf zqt dsd lqx ljq grl +srb: xzd +htr: jxl frh +dtd: jdp zrr dpm hth hbn fcv +lmz: mpn +vdh: jkg rbk klr lvm +fxn: spq +rnt: pps hmh vjh zxf +dqb: vxl jxx +hff: msg +dml: snd zjt +jxr: kgc rcm mhr +spt: fqv scl kfd +bbv: rsm cff xsv xgk jvv +shm: tgt vqp qgm +fdx: hgs +bhd: grh +ktm: mpb gtl zls dpd +msf: bcs sxc +hhv: cdx +vqq: rjb +shx: lnt jtp +rgg: hnh qcc vhp dml +bnq: qvz qbq +rpg: sqr dpm rtx +tcn: trh +dgv: vlf jkk bjf +bkf: vdf +rgj: fsn +mfc: ccl kjg gsl tpq +qmj: clm qfj rtm vbm nvr +pll: rfv +fbh: hnd hdd zxc hdf flj +kns: sfv chc pjc dvq +mvs: ckm mjh +qtt: fxc sck ssb +hkn: qsf +kjc: tks xmj +lmb: hbh plm tsn hjz +tdh: rrr zzn clp xfq +djz: tql fvz qdm +pth: sfv +cjb: fvl klk nfj +hgs: bjf +vgp: ckg bxb +xbd: lrz vqq +prn: zkn llm pbs drg kbk +nxr: mqj qmk smz zll +xfn: fnj hnd +qmx: cvr krh npm +xht: qlz hsn +pzc: fht +psz: rnq fnh gsc +ccx: sch jjq slg qgv +bln: kcd fzv thg hff +llm: jvv zjg zcr skb tqt +shd: vbm cdx +lhx: pdj jxs fzq gft +zzg: rhj trr +sjg: nxr fbt xdf tgp +fjt: tqz vcq hkf +vrc: bpb lll +jjs: jfp jqp plm vqh mpg +lxc: tkd gvs psm dsr +vvr: htr rcx gmt shm +lpb: dbn jms +pfd: pcr ktj +khk: fbr cjp lbj +ssv: ktj czt +ktt: qcl fzv vxl +fsd: dkz lqh +vrg: xmm jfs nfk +qdf: kms tvm ggb +xgh: xbd hqg +jdp: mxk +vbs: jzn nmh hbr jdp +rxd: mmx fxc pcr kdz +nlc: vnf cxp +mqp: xjd kbp jvr hjb +sqt: tkd jcg mqm +gzr: mgk +lxd: gtp rrp hkn +cpd: mls crx ltm +hpb: smd mdd rqx +cdh: frh nts +gsc: szx tpq +xdn: nxl knr +hnv: klk snq xgq tjt +zhh: lzf +rph: jvj mct ddq +zct: jxx +nfd: lps +nmz: pth zcr mnl +jlh: bpr dzf nhx qmk nfd +rbb: qsc tpm +ldd: dvq +vtz: smx ksf bgz +trl: ldm nvs qvf +lnp: lvm fdv hzs hlx +jpb: gjd nvs mhr jxl +cgd: ttq xcj dgz rnd +xrb: bld tzf +dmr: dlj +rjs: hdf +vbq: qjj pll dbl pbx +ppg: mrg +lgp: khn prz qzd dfz +jzz: gdp qsn +ljk: fsl qsf gzr pll diff --git a/aoc2023/day25/main.go b/aoc2023/day25/main.go new file mode 100644 index 0000000..9197e13 --- /dev/null +++ b/aoc2023/day25/main.go @@ -0,0 +1,63 @@ +package main + +import ( + "bufio" + _ "embed" + "fmt" + "iter" + "strings" + + aoc "go.sour.is/advent-of-code" +) + +// var log = aoc.Log + +func main() { aoc.MustResult(aoc.Runner(run)) } + +type result struct { + valuePT1 int + valuePT2 int +} + +func (r result) String() string { return fmt.Sprintf("%#v", r) } + +func run(scan *bufio.Scanner) (*result, error) { + g := aoc.Graph[string, int]() + var root string + + for scan.Scan() { + line := scan.Text() + v, lis, ok := strings.Cut(line, ": ") + if !ok { + continue + } + + if root == "" { + root = v + } + + for _, l := range strings.Split(lis, " ") { + g.AddEdge(v, l, 1) + g.AddEdge(l, v, 1) + + } + } + + for i, v := range enumerate(g.BFS(root)) { + fmt.Println(i, v) + } + + return &result{}, nil +} + +func enumerate[T any](vs iter.Seq[T]) iter.Seq2[int, T] { + i := 0 + return func(yield func(int, T) bool) { + for v := range vs { + if !yield(i, v) { + return + } + i++ + } + } +} \ No newline at end of file diff --git a/aoc2023/day25/main_test.go b/aoc2023/day25/main_test.go new file mode 100644 index 0000000..5a72d65 --- /dev/null +++ b/aoc2023/day25/main_test.go @@ -0,0 +1,41 @@ +package main + +import ( + "bufio" + "bytes" + "testing" + + _ "embed" + + "github.com/matryer/is" +) + +//go:embed example.txt +var example []byte + +//go:embed input.txt +var input []byte + +func TestExample(t *testing.T) { + is := is.New(t) + scan := bufio.NewScanner(bytes.NewReader(example)) + + result, err := run(scan) + is.NoErr(err) + + t.Log(result) + is.Equal(result.valuePT1, 50) + is.Equal(result.valuePT2, 0) +} + +func TestSolution(t *testing.T) { + is := is.New(t) + scan := bufio.NewScanner(bytes.NewReader(input)) + + result, err := run(scan) + is.NoErr(err) + + t.Log(result) + is.Equal(result.valuePT1, 0) + is.Equal(result.valuePT2, 0) +} diff --git a/grids.go b/grids.go index cf0b893..5dba5c5 100644 --- a/grids.go +++ b/grids.go @@ -199,10 +199,10 @@ func (g *graph[V, W]) AddEdge(from, to V, w W) { return } if _, ok := (*g)[from]; !ok { - return + g.AddVertex(from, from) } if _, ok := (*g)[to]; !ok { - return + g.AddVertex(to, to) } (*g)[from].Edges = append((*g)[from].Edges, edge[V, W]{(*g)[to], w})