diff --git a/Cargo.toml b/Cargo.toml index 050a474..0f6fd6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,5 +7,7 @@ edition = "2021" [dependencies] anyhow = "1.0" itertools = "0.10" -num-traits = "0.2.15" +lazy_static = "1.4" +num-traits = "0.2" +regex = "1.7" thiserror = "1.0" diff --git a/data/day07/example01.txt b/data/day07/example01.txt new file mode 100644 index 0000000..bcbb513 --- /dev/null +++ b/data/day07/example01.txt @@ -0,0 +1,23 @@ +$ cd / +$ ls +dir a +14848514 b.txt +8504156 c.dat +dir d +$ cd a +$ ls +dir e +29116 f +2557 g +62596 h.lst +$ cd e +$ ls +584 i +$ cd .. +$ cd .. +$ cd d +$ ls +4060174 j +8033020 d.log +5626152 d.ext +7214296 k \ No newline at end of file diff --git a/data/day07/input.txt b/data/day07/input.txt new file mode 100644 index 0000000..303ed1c --- /dev/null +++ b/data/day07/input.txt @@ -0,0 +1,1135 @@ +$ cd / +$ ls +233998 glh.fcb +184686 jzn +dir qcznqph +dir qtbprrq +299692 rbssdzm.ccn +dir vtb +$ cd qcznqph +$ ls +32148 lhsrj.fnr +dir lnj +dir mtr +dir mznnlph +dir pdtpt +24836 rsjcg.lrh +dir vrj +dir wrqcfl +$ cd lnj +$ ls +12592 tlh +$ cd .. +$ cd mtr +$ ls +118870 twdhlmp.gbw +$ cd .. +$ cd mznnlph +$ ls +240977 fmmhnhtf +dir gbhcnts +dir gsbjrrd +dir pmwcs +dir qtbprrq +286007 rhnjndsq.gst +dir twdhlmp +283716 twdhlmp.rpr +$ cd gbhcnts +$ ls +dir fctrnwb +dir gbhcnts +46017 gft.hvm +234925 gjsnzbtw.ncd +dir nvnwh +dir srslsjp +dir swtlfsv +66115 tgpmsb +64086 tqnvb +308270 tqwfpnbn.btp +$ cd fctrnwb +$ ls +112643 qhcdd +$ cd .. +$ cd gbhcnts +$ ls +26196 cmttgsmm.bdn +317410 fthqln +dir lwshph +32809 tdmfc +dir tqcllnv +dir twdhlmp +$ cd lwshph +$ ls +214023 ctqvrzs.jvr +104432 gbch +dir gpqgrw +105909 qshbtd.nml +dir rhhsfbdd +dir svvqh +161439 tqnvb +60152 twdhlmp.qzw +$ cd gpqgrw +$ ls +dir mbsgrlld +dir nhb +dir qtbprrq +$ cd mbsgrlld +$ ls +13247 tsztmlfg +dir twdhlmp +$ cd twdhlmp +$ ls +236804 mcrd +$ cd .. +$ cd .. +$ cd nhb +$ ls +86570 gtvnbsv.zbr +$ cd .. +$ cd qtbprrq +$ ls +111178 npg.qph +110775 tlh +$ cd .. +$ cd .. +$ cd rhhsfbdd +$ ls +37729 fmmhnhtf +263415 ljvwzj.btm +$ cd .. +$ cd svvqh +$ ls +185682 wlcl.fhs +$ cd .. +$ cd .. +$ cd tqcllnv +$ ls +dir cbdj +dir ccsfm +55264 tqnvb +267792 wlcl.fhs +$ cd cbdj +$ ls +128247 fmmhnhtf +dir mtnbs +240520 ngmw.clj +30569 qbqltr.lbw +188801 zwdpp +$ cd mtnbs +$ ls +dir bsfbrmh +dir ftmnrwm +$ cd bsfbrmh +$ ls +dir tltvzp +$ cd tltvzp +$ ls +312469 dnst.sbm +$ cd .. +$ cd .. +$ cd ftmnrwm +$ ls +278974 nlztftc.zhb +$ cd .. +$ cd .. +$ cd .. +$ cd ccsfm +$ ls +4017 wlcl.fhs +$ cd .. +$ cd .. +$ cd twdhlmp +$ ls +dir qtbprrq +$ cd qtbprrq +$ ls +dir tdpz +$ cd tdpz +$ ls +210400 fmmhnhtf +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd nvnwh +$ ls +dir jlpbbds +dir pphv +285452 qtbprrq +$ cd jlpbbds +$ ls +7058 vmrcqz +$ cd .. +$ cd pphv +$ ls +290310 msz.swz +$ cd .. +$ cd .. +$ cd srslsjp +$ ls +dir nnz +192902 twdhlmp.vgp +$ cd nnz +$ ls +215711 tlh +$ cd .. +$ cd .. +$ cd swtlfsv +$ ls +274236 frwncp.gff +$ cd .. +$ cd .. +$ cd gsbjrrd +$ ls +dir dnst +dir gbhcnts +61000 gqdf +175813 jvz +dir ldqjzrtp +$ cd dnst +$ ls +124352 dnst +220618 mzsqzbfz.qfd +134211 qmrvh +dir qqlm +dir qtbprrq +223840 tlh +dir twdhlmp +24794 wfb.rtf +$ cd qqlm +$ ls +113976 wlcl.fhs +$ cd .. +$ cd qtbprrq +$ ls +212775 qtbprrq.ngs +$ cd .. +$ cd twdhlmp +$ ls +308083 fzhd +63311 wlcl.fhs +$ cd .. +$ cd .. +$ cd gbhcnts +$ ls +dir dlvhzdbg +$ cd dlvhzdbg +$ ls +305798 twdhlmp +$ cd .. +$ cd .. +$ cd ldqjzrtp +$ ls +93085 dcvfpz.bjl +264488 zssvm.wdp +$ cd .. +$ cd .. +$ cd pmwcs +$ ls +125444 qtbprrq.tgl +$ cd .. +$ cd qtbprrq +$ ls +dir bjnctfv +133127 fmmhnhtf +dir gztmrrff +dir qtbprrq +$ cd bjnctfv +$ ls +dir cpwrcf +dir fdjzsfc +1223 gbhcnts.qvf +272526 gbhcnts.sgs +dir qnsdl +dir snq +dir tmjnvcbl +dir vdjqsbr +271339 wslnqh.rgr +134589 zzqrbr.fcz +$ cd cpwrcf +$ ls +143124 pdr +$ cd .. +$ cd fdjzsfc +$ ls +dir gbhcnts +dir nqpbzvpq +$ cd gbhcnts +$ ls +151265 jrdvt.fcg +11872 tlh +$ cd .. +$ cd nqpbzvpq +$ ls +dir hpwhslq +27858 ljvwzj.prq +dir nzcnb +$ cd hpwhslq +$ ls +136646 bqgj.wvw +252823 ngmw.clj +137072 tqnvb +$ cd .. +$ cd nzcnb +$ ls +99882 twdhlmp.grg +$ cd .. +$ cd .. +$ cd .. +$ cd qnsdl +$ ls +8925 fmmhnhtf +dir mnzqwfnh +206990 vqgrhqgc +$ cd mnzqwfnh +$ ls +271442 bmztfjlc.lzr +$ cd .. +$ cd .. +$ cd snq +$ ls +25995 tqnvb +$ cd .. +$ cd tmjnvcbl +$ ls +dir gclzbvt +$ cd gclzbvt +$ ls +dir jtfddbs +$ cd jtfddbs +$ ls +10564 pdf.tsj +32415 tlh +$ cd .. +$ cd .. +$ cd .. +$ cd vdjqsbr +$ ls +256668 cwbd +265036 fmmhnhtf +$ cd .. +$ cd .. +$ cd gztmrrff +$ ls +52260 bdqcl.bdw +dir lsss +120102 tlh +$ cd lsss +$ ls +13729 wlcl.fhs +$ cd .. +$ cd .. +$ cd qtbprrq +$ ls +dir bttpq +dir lcvgwpt +$ cd bttpq +$ ls +216247 nnlv.dgl +138688 wlcl.fhs +$ cd .. +$ cd lcvgwpt +$ ls +dir dth +198570 tsqgm.zht +dir zbcstsb +$ cd dth +$ ls +dir cqmbtj +120437 hdqp.vhq +dir vpzn +$ cd cqmbtj +$ ls +11882 sdngnzb +$ cd .. +$ cd vpzn +$ ls +dir jqbz +271714 plcq.bfg +$ cd jqbz +$ ls +dir qqhnfglj +136307 stncbrm +177843 tlh +168253 tqnvb +297085 wcn +$ cd qqhnfglj +$ ls +197471 twdhlmp +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd zbcstsb +$ ls +298115 bvljmpc.gss +308872 ljr.lzl +201657 ngmw.clj +170617 ppln +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd twdhlmp +$ ls +dir dbb +277215 ngmw.clj +310263 twdhlmp.wvs +dir vsfrqsnl +$ cd dbb +$ ls +258300 tqnvb +$ cd .. +$ cd vsfrqsnl +$ ls +dir gbhcnts +12285 tlh +$ cd gbhcnts +$ ls +248251 dnst.bcs +91471 gbhcnts.ntr +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd pdtpt +$ ls +164477 flcgj.zwr +dir ljvwzj +51483 ljvwzj.htl +dir pbtr +dir qtbprrq +dir rrhcsn +$ cd ljvwzj +$ ls +dir nsq +133318 qtbprrq.gqq +166365 rnfbl.ljh +130617 tlh +16112 vbw +$ cd nsq +$ ls +dir fwfcmfbz +$ cd fwfcmfbz +$ ls +71451 zcc.ngn +$ cd .. +$ cd .. +$ cd .. +$ cd pbtr +$ ls +dir qtbprrq +$ cd qtbprrq +$ ls +117780 gjqbnrv.sdl +$ cd .. +$ cd .. +$ cd qtbprrq +$ ls +269746 dld +dir fcmbv +42544 mlzvd.vcw +165396 nbtlfm.vzq +dir sbtl +dir twdhlmp +$ cd fcmbv +$ ls +202047 wdzcrg.mcg +$ cd .. +$ cd sbtl +$ ls +dir dbcdf +dir fbz +dir lvz +dir ncnwbsdh +dir rft +23523 zphlfqf.phv +$ cd dbcdf +$ ls +dir dhdw +dir dvtjfhvm +182513 lclmdwr +63921 ngmw.clj +dir qqmddq +318020 tlh +dir twdwfj +83108 vmwlfdlf +121901 wlcl.fhs +$ cd dhdw +$ ls +dir qtbprrq +dir twdhlmp +dir wbllhmd +$ cd qtbprrq +$ ls +111984 fhc.tzm +$ cd .. +$ cd twdhlmp +$ ls +277414 fwfqbb.dpj +$ cd .. +$ cd wbllhmd +$ ls +dir dnst +dir jqz +dir lbdclnfb +dir ljvwzj +dir mzfdg +96340 ngmw.clj +dir twdhlmp +dir wmcfzznt +147877 zwgvvd +$ cd dnst +$ ls +310179 fmmhnhtf +243908 twdhlmp +$ cd .. +$ cd jqz +$ ls +94739 twdhlmp +$ cd .. +$ cd lbdclnfb +$ ls +112509 ljvwzj +$ cd .. +$ cd ljvwzj +$ ls +28274 bshlmj.lzc +84072 tlh +283462 twdhlmp.ccd +$ cd .. +$ cd mzfdg +$ ls +282099 hbbrjc.jff +63535 tlh +$ cd .. +$ cd twdhlmp +$ ls +283817 jltvl.tgl +$ cd .. +$ cd wmcfzznt +$ ls +294565 fmmhnhtf +$ cd .. +$ cd .. +$ cd .. +$ cd dvtjfhvm +$ ls +292813 qgmvm.fsg +$ cd .. +$ cd qqmddq +$ ls +11670 dnst.btd +241275 fmmhnhtf +196615 fpnmptm +dir nnzscbvw +dir qnrr +$ cd nnzscbvw +$ ls +250962 dflhdfz +$ cd .. +$ cd qnrr +$ ls +dir trzj +$ cd trzj +$ ls +36993 gbhcnts.rdh +273052 tlh +$ cd .. +$ cd .. +$ cd .. +$ cd twdwfj +$ ls +162470 hfdhmbcq.hwz +dir qtbprrq +dir scjzbdsz +2609 wlcl.fhs +$ cd qtbprrq +$ ls +dir cfmglhwj +103703 cscftrsr.jbs +71160 dnst.rbw +dir nrmp +311716 qtbprrq +$ cd cfmglhwj +$ ls +dir fmcmjfg +$ cd fmcmjfg +$ ls +82998 ljvwzj.qbd +8407 nhmmwwzl +dir qtbprrq +261949 tlh +$ cd qtbprrq +$ ls +314421 hwqtl +92593 zcdvf +$ cd .. +$ cd .. +$ cd .. +$ cd nrmp +$ ls +94387 fmmhnhtf +$ cd .. +$ cd .. +$ cd scjzbdsz +$ ls +6861 dgzhldd.dhs +dir gbhcnts +dir qtbprrq +dir sfdl +$ cd gbhcnts +$ ls +dir qdsrs +$ cd qdsrs +$ ls +25165 ngmw.clj +$ cd .. +$ cd .. +$ cd qtbprrq +$ ls +151403 tswd.hpf +$ cd .. +$ cd sfdl +$ ls +308622 jcmsnj +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd fbz +$ ls +dir dgjf +dir qtbprrq +$ cd dgjf +$ ls +254198 rvf.hfq +$ cd .. +$ cd qtbprrq +$ ls +dir frlj +231222 njjfqgt.bph +dir rjsw +dir vjhzc +$ cd frlj +$ ls +dir ljvwzj +$ cd ljvwzj +$ ls +57572 ljvwzj.bvh +$ cd .. +$ cd .. +$ cd rjsw +$ ls +131875 lbcq.rlc +272908 mnfs +$ cd .. +$ cd vjhzc +$ ls +279363 fmmhnhtf +238051 zdzbb.rfj +$ cd .. +$ cd .. +$ cd .. +$ cd lvz +$ ls +289192 tqnvb +dir twdhlmp +$ cd twdhlmp +$ ls +dir wqtgwzdn +$ cd wqtgwzdn +$ ls +283475 ghvpfl +$ cd .. +$ cd .. +$ cd .. +$ cd ncnwbsdh +$ ls +dir dfrdwfgm +dir ljvwzj +dir vgh +$ cd dfrdwfgm +$ ls +279286 mrbwmws.nzd +197337 nqgq.fhf +248096 tqs.jfb +35181 wlcl.fhs +$ cd .. +$ cd ljvwzj +$ ls +250455 gmph.scm +147449 ljvwzj +100189 qfr +$ cd .. +$ cd vgh +$ ls +244540 bzwrldnz.ldt +235508 dzm +dir gbhcnts +dir qtv +dir tvtwlt +262356 wlcl.fhs +$ cd gbhcnts +$ ls +160689 srvpbf.szt +191895 tqnvb +$ cd .. +$ cd qtv +$ ls +9491 dnst.szf +268602 ngmw.clj +dir pbcrfzz +39049 rzgqqvlt.nsm +dir tfpl +79589 wwcrv.ncv +$ cd pbcrfzz +$ ls +dir stt +256685 wlcl.fhs +$ cd stt +$ ls +12650 jbdfwj +$ cd .. +$ cd .. +$ cd tfpl +$ ls +92079 dfhj +$ cd .. +$ cd .. +$ cd tvtwlt +$ ls +dir cqv +$ cd cqv +$ ls +dir vdv +$ cd vdv +$ ls +119483 fmmhnhtf +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd rft +$ ls +24341 bjhzvzp.flg +dir glwdmdt +$ cd glwdmdt +$ ls +288082 jdtlwrzh.wcj +$ cd .. +$ cd .. +$ cd .. +$ cd twdhlmp +$ ls +dir gbhcnts +154240 wlcl.fhs +$ cd gbhcnts +$ ls +217462 ddzp +$ cd .. +$ cd .. +$ cd .. +$ cd rrhcsn +$ ls +308440 dzbfl.vcg +dir jbhcpdh +238941 rnqdz +dir szljjhc +$ cd jbhcpdh +$ ls +dir bmg +dir mdqplln +dir twdhlmp +dir zbt +$ cd bmg +$ ls +dir djwfl +dir gbhcnts +dir ljvwzj +142159 mwl.psh +110681 rzmdgbng +dir zqjbb +$ cd djwfl +$ ls +dir dpfcrjl +dir rqtz +$ cd dpfcrjl +$ ls +206939 tlh +$ cd .. +$ cd rqtz +$ ls +232264 tlh +$ cd .. +$ cd .. +$ cd gbhcnts +$ ls +186364 ngmw.clj +248882 twdhlmp +306411 wjqvlzp +$ cd .. +$ cd ljvwzj +$ ls +dir dgqw +$ cd dgqw +$ ls +dir mpczlcrz +dir qtbprrq +dir twdhlmp +dir zjsltthh +$ cd mpczlcrz +$ ls +142906 gvd.nnz +$ cd .. +$ cd qtbprrq +$ ls +179566 fmmhnhtf +309800 jhwwppc.vcp +$ cd .. +$ cd twdhlmp +$ ls +dir bhqjhjvp +$ cd bhqjhjvp +$ ls +dir lmj +dir qmcqggbl +$ cd lmj +$ ls +275070 twdhlmp +$ cd .. +$ cd qmcqggbl +$ ls +dir mhgnpm +$ cd mhgnpm +$ ls +dir rnzzqr +$ cd rnzzqr +$ ls +126574 pgnlrjs.czj +7567 tqnvb +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd zjsltthh +$ ls +dir twdhlmp +$ cd twdhlmp +$ ls +198813 dnst.cqc +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd zqjbb +$ ls +dir czdvd +94020 dnst +46041 qtbprrq.pzm +dir rcfvq +dir rwj +118305 vbcpcz +48725 wlcl.fhs +$ cd czdvd +$ ls +302317 tlf +$ cd .. +$ cd rcfvq +$ ls +dir cjws +$ cd cjws +$ ls +dir dsgf +dir fvqbhq +203941 hgcbcvb +9562 qqjh.mfh +32161 qtbprrq.tgn +225251 sbmpn +dir sdhvcj +$ cd dsgf +$ ls +dir cbwzg +141466 ctpszzvn.qrq +277153 ngmw.clj +100681 vmdwgrp +$ cd cbwzg +$ ls +dir nblvrbv +$ cd nblvrbv +$ ls +129474 dlcbng.sgf +$ cd .. +$ cd .. +$ cd .. +$ cd fvqbhq +$ ls +75755 fmmhnhtf +229463 tlh +$ cd .. +$ cd sdhvcj +$ ls +306751 tqnvb +$ cd .. +$ cd .. +$ cd .. +$ cd rwj +$ ls +130415 cjbz +283701 rgsdtn +$ cd .. +$ cd .. +$ cd .. +$ cd mdqplln +$ ls +169404 dvss.mvd +105385 fmmhnhtf +222834 jhzpwscp.sqg +164293 jsqlprqn.vnp +57167 pwpjfq.bmb +dir qtbprrq +$ cd qtbprrq +$ ls +62823 ljvwzj.flm +252940 tlh +$ cd .. +$ cd .. +$ cd twdhlmp +$ ls +dir dhvgfhc +dir qrlq +$ cd dhvgfhc +$ ls +dir vpldlp +$ cd vpldlp +$ ls +279067 dnst.jfs +9050 fmmhnhtf +88586 mfbj.fgs +$ cd .. +$ cd .. +$ cd qrlq +$ ls +dir qwwftl +$ cd qwwftl +$ ls +103153 tnczww +$ cd .. +$ cd .. +$ cd .. +$ cd zbt +$ ls +99657 fsq.rzj +158138 gbfjfctj.bgg +260423 tqnvb +161379 trg +$ cd .. +$ cd .. +$ cd szljjhc +$ ls +287080 stnp.lgp +173682 wjzvglm.lfm +$ cd .. +$ cd .. +$ cd .. +$ cd vrj +$ ls +129084 ngmw.clj +250696 pdpzzbs +$ cd .. +$ cd wrqcfl +$ ls +dir bjlwb +105899 gsvm +dir jdnjpg +178665 znnmmhqt.hth +$ cd bjlwb +$ ls +207939 gbhcnts +$ cd .. +$ cd jdnjpg +$ ls +260418 tqnvb +302144 twdhlmp.ghg +$ cd .. +$ cd .. +$ cd .. +$ cd qtbprrq +$ ls +95562 fmmhnhtf +dir plf +dir qtbprrq +306396 rqqmm.wvw +dir wpfj +$ cd plf +$ ls +dir fmftrbn +20347 twb.zjd +$ cd fmftrbn +$ ls +dir rfznrm +$ cd rfznrm +$ ls +283327 rlzjcg +$ cd .. +$ cd .. +$ cd .. +$ cd qtbprrq +$ ls +313931 ztmhrjc +$ cd .. +$ cd wpfj +$ ls +3969 wrbhb.jll +$ cd .. +$ cd .. +$ cd vtb +$ ls +14260 fmmhnhtf +dir gbhcnts +dir lwcznw +dir mhp +dir pqcddzsf +272267 qgh +301727 rsjrn.wjg +101787 vqscjb +dir zvn +$ cd gbhcnts +$ ls +7627 tqnvb +$ cd .. +$ cd lwcznw +$ ls +98498 dnst.tds +dir gfh +dir jdg +dir llnl +161511 mtmrr.hvb +dir ppzwbgnz +210908 qtbprrq +dir tvhz +$ cd gfh +$ ls +169547 mjjvvlqj.jmv +$ cd .. +$ cd jdg +$ ls +dir cthptwcf +dir ljvwzj +dir vnlndl +$ cd cthptwcf +$ ls +98711 qwzwz.qct +$ cd .. +$ cd ljvwzj +$ ls +245473 zhptcmcr.fts +$ cd .. +$ cd vnlndl +$ ls +151466 ljvwzj +285091 twdhlmp.mzv +59067 vcdpbg.nmp +$ cd .. +$ cd .. +$ cd llnl +$ ls +141508 phtmjj.qzl +dir qtbprrq +105151 tlh +$ cd qtbprrq +$ ls +62020 hdzljht.fvq +$ cd .. +$ cd .. +$ cd ppzwbgnz +$ ls +298940 pzdqzrn.zlz +$ cd .. +$ cd tvhz +$ ls +96628 hrzr +$ cd .. +$ cd .. +$ cd mhp +$ ls +226604 mbdn.tbq +dir ndgqtvhg +$ cd ndgqtvhg +$ ls +55244 dnst +dir sljbrmhb +$ cd sljbrmhb +$ ls +32711 dnst +$ cd .. +$ cd .. +$ cd .. +$ cd pqcddzsf +$ ls +dir shwrrq +$ cd shwrrq +$ ls +dir dplcwvhg +dir pvtpf +dir qpsmgfjl +247965 rrw.wwv +dir vmrwpt +$ cd dplcwvhg +$ ls +242534 fmmhnhtf +202367 fzmt.qrw +197586 ljvwzj.qgm +dir stp +dir zpz +$ cd stp +$ ls +12921 mlcqtthb.jtd +$ cd .. +$ cd zpz +$ ls +235965 ngmw.clj +$ cd .. +$ cd .. +$ cd pvtpf +$ ls +319563 rdspj.slv +279577 vqpjzrdl.hhj +$ cd .. +$ cd qpsmgfjl +$ ls +131841 cqhrgc.cqz +105373 fbnp +$ cd .. +$ cd vmrwpt +$ ls +176373 phgsdlnj.ggq +$ cd .. +$ cd .. +$ cd .. +$ cd zvn +$ ls +dir gbhcnts +dir gfh +dir ppqjzln +dir qtbprrq +$ cd gbhcnts +$ ls +156292 wlcl.fhs +$ cd .. +$ cd gfh +$ ls +189836 ljvwzj.wpt +10416 zbnhzjvw.jct +$ cd .. +$ cd ppqjzln +$ ls +95088 sszd +$ cd .. +$ cd qtbprrq +$ ls +295187 hnnl +292421 qtbprrq.ppg +220281 wlcl.fhs \ No newline at end of file diff --git a/data/day08/example01.txt b/data/day08/example01.txt new file mode 100644 index 0000000..6557024 --- /dev/null +++ b/data/day08/example01.txt @@ -0,0 +1,5 @@ +30373 +25512 +65332 +33549 +35390 \ No newline at end of file diff --git a/data/day08/input.txt b/data/day08/input.txt new file mode 100644 index 0000000..451fe1b --- /dev/null +++ b/data/day08/input.txt @@ -0,0 +1,99 @@ +131102031022411233124153000402524132243245422402002121234345453535321113450535302430144220243210033 +210030011133442111442145434004231353202400601331445042106230540242340014332243105022302133441101011 +201302044230110302341330012044051130055046354663404014033243655520410125432425532024143403330032232 +210303103204034020151134514120046162664361356330261302226530654326452225134535222440444443410101130 +021310332113230035544033314213544254421233042151226601345516101654005025035545035333140023212102212 +220140301231432453044535532323066560244052510442522465306425021511260132313424322110345422300411332 +103013240142011245425311001542145655516105003352455141424412415222100145355043202120423034202120403 +314103304322445325255534650156565303510461206034672755654106425161056213552330050310445352323213402 +243430113305332145305400366156126611120357766767667531265661631510215134106224240155532142014202020 +344044011305120500223111213354316112154646744635155132374774442641061323024416155344101304242413014 +210001340311202411013214565026366577746364242672331436164352252445110000414212215202321411504422400 +001030344254033552521244445311464542617442572153467545366653342426676363026234406640015310103000111 +123004351234415456501532136126535464236513321263256111263236363424471316560661104630322511135024314 +243444301010130503501065440067414335615573435151661324666436573133444251763541254166141130405531401 +301333054435342646553265615125271561444757162666247563564724434377461174733226461663122454115301022 +313333115034033032461152521554721624436564356545874583322623147632365263427634464233444421123452114 +434441324240044110131332722354256132333522657745624745724323263635746316535120231124164652542245541 +020013043025261604606066777717675561448878622688884553346728286853164272251311263510330645452212040 +225405401530036646635664123763243188844858643328244728344354343287813231363771264361344552214134043 +444013205241103641532477643143435563484567276423226466226434857664377176552653732212146514023430325 +235444033555452351644577725572733823223422438445886848336238372267477767173715122521014452405344110 +022222500504231055646646534633724257646568684735488756288737857786232268232655151633323530463425151 +412102254551210100735562467375656382325864659764674335534465738553284326347575542675435335613154320 +202304233522424114651647265763556544532358373769578879369385574555386666783363244334360301665155255 +400235422666401262236327746826382638573848989589958764697958946664233887757677777164614616200413302 +413211350405512664175712772346875822558798479568486643787487763573785465875336133314155235265153544 +412112650043523364626154522655787734369585968849884958638795656846722736645822544573361050432101002 +040151232015244534675233447267274466883354564933934639355395374945757347634723116764261154205631025 +053511566106055552733487866435428673379594867554589579573759867856436754328455243315565403452366550 +402441261342655261311663778728277373873487457867467678497684746937764462833722831553364205512206541 +401560462601374333165687778774966694644847875679669694796453568554383377242683474675113640166014002 +245431640441276372256235534578677594558499466595957658548574676357557473852362834636123725105611001 +140325466637452621767678632447835458776865576466546548894776445753494487385328422645157221103664133 +253440020224216474125727543697395446885846849486744757588954688447585337348374328857266123303626032 +522360463154354425644334277863647479565896696996775849896649575745746557964548536537415577142552050 +402351634474624167474857559553949899894799879644496759587555549787974996993634823833353424316316042 +414140006077774645384224689955449865767867876647679668857949995687773539976755288762714471242526254 +032242255462211412258653836566746764685477947565799869886769647489953985859547537844111624535631156 +241646435225236526565228495485878686676559956669957869665758947786478934645637286347261114426145563 +512215356337536722737525437473645894558456658976958699776986594778559569864962457825216143344215016 +322625244746336257345525895486859454957989669585766859958667775649875866654855238722721513671212305 +044600535247217686848675385837958687859856856865869679556868995579875763985654342678317263541605554 +430320424173321746345287493633447589689698796959599858768985856685945573454358785585284454656334025 +232026013361136674773333583555589876467998965697988698997966777468454666855894285223681327425505166 +354332536226232536453676489538955896788985786767799998876886965757444485955456462568453444425456521 +016154147271566788586769489946847647867857556667888797775895768988576579978395627453672756147414326 +463454162462563733454784956555887864475857986666689767978699985965647598648778424456255355723655466 +021001072567511684363734454496747746785559778677966778897776558954997794766634668356686124441524525 +234605435156344755776859794859864756797769876888968689787579998559856654953446748662382433262116262 +030666223611312438477278595797684446757958596668696976678757986797965899875556377876865147373650335 +245046541536764737224694794369857786796969878968689968797958865856864988656773724353268427134461620 +265066622261247542566375373496969757789659688887789988798956868878668565665794723743572475263161166 +422245453144736877586299945587888888767997586686876996879786788998867747683776448657845662361505315 +210351625547722865278485967857788659769765586689699988976775596895984657648869967252632246417436621 +141004614422116428487735355858968995455599988699767679796595755979678769336598642342483777532511004 +533362561377622426377686383498446767487997987976886899988585956569875694463399574483265564264622314 +456163507723454276868637866355647859456998677889778989889969998954684957667483346372863274465245646 +030644251421316636263479555487765499846688669798677798668968599994746869757876565775844144255106462 +510135336311735337436764935399965949469956999767696876898578576969547984463869253278467243311543030 +466524526117724766584368696865578944888566858759789698699778689456856774865884337672615767136523254 +254110631463762333865539645936466585858655857657659586556989585456479575455563845762632676471423233 +562434653773762262468663566995359545869887797866957588766855659579865834576343438465353323754454240 +112066240641477224475587449447989749648974898785555767886979489566644938356955638286634724441631625 +330443313353347713822865768695549469777556759786896565758769775757475566378642426537546311412140051 +040065350247621726448577745444446666557767548565886798996759654466566755698345662584625446342463260 +330536625076531353825376746548345995946649894668956867559446757474398638639624464682343654214032311 +530251120326432762683357643388548466489576697998869899549584977659746869733837538723573545213461105 +255356015316555756432734833639785737748988987965669458947565666746847669548847254811135737404226043 +454354550123557227257454326863468487794448666674495859497588676766356646553276336612337324063553462 +144340525160235512164242786385886753536996894579865659848488534457479379684556654637432614663443613 +305316054035171372138527636345993984687638579458566486795488343446895753373444445772513544116215313 +543055400456632262131666826787874497775946535566897457748984377394483964377555447341647525602315351 +412546632444321676125286364645444448636496473746537653585847369856994564666782226566264742530022340 +044233444612165527122563533685825959374668734768758953663536843946435452847223172365277563546141540 +340030454102343151253211647666557354334348799955649644348678747758347287426221514313112316663165454 +011020051334501654522762446268866586389746656669789443696677886848328248582411315534364123146250501 +305413453334030464614216442476475733478966457359966737766476988846463467574624373625606065562242335 +034215112203016427473135421577622448726677469646375339565639944867546662453345521671403262325021214 +132210543140531252452317342463454885388566728556533533877354846446665578244115675240031664244524501 +201140051634662646614612354714626525722377445426842485568735384726362363654642742661135663265002510 +025011353243541235316415314133578633558245363633567643474723462264656821637416273202656565602515322 +121540314222665224011553176734444466578255884322834667368468238484254776573264467333645106223352155 +233134314541654641520531771126551528746557387438726348653238283875537147555615754035502132555444301 +424510000505066600303343337525732714723283556468834467558232644677477536766533666404266150255104242 +041433452552331436330125237255465337374884372735358382327855756643676341445255435062065033314033212 +141025211241314363206626056633223121353133645783244374622462256271457773212200625560321421020100213 +224101010422251643133220616233621223532466525114754865347141165612135423157400060111225313054434032 +004040052225144131342364656025377722754756627621767354111575442445436452322335541156250421012350243 +043322120521041516241540153402233524371432721521521276133447761312616332565246332656140342120501432 +200232013354533102134562014146621725413251577715376671261144475237357064044430050234040121014304202 +011420212054031401033241133121106532344212712314572323662643147467661343340045361122545415103011124 +102223410325432324313243446514164004156475643254444557477323147134144354265066260422110450012141414 +031411112311321035125554420606413626050373327654774373667767140605036115333551650220414205214132024 +210204032200320524351051665115025502044361230251377575706601164652440120455165201034431244211004301 +331131223444034015143142430503454436431142412165246111316106164251614223504203533022310134023423343 +120300034332102045152234220042512653414152606411234665213124345325420542210314454221024423343223220 +200230420442302210441134513143532363040132120013505235035543064245636124512505054404233133430423011 +000202411243122420140310501035333204626352325031215630345206242502134153000033354044334042221310101 +111301302244231442013332415144033330063530643146335532313306033656410450441505505240142210004121122 \ No newline at end of file diff --git a/data/day09/example01.txt b/data/day09/example01.txt new file mode 100644 index 0000000..cbea2b3 --- /dev/null +++ b/data/day09/example01.txt @@ -0,0 +1,8 @@ +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2 \ No newline at end of file diff --git a/data/day09/example02.txt b/data/day09/example02.txt new file mode 100644 index 0000000..c1eba0a --- /dev/null +++ b/data/day09/example02.txt @@ -0,0 +1,8 @@ +R 5 +U 8 +L 8 +D 3 +R 17 +D 10 +L 25 +U 20 \ No newline at end of file diff --git a/data/day09/input.txt b/data/day09/input.txt new file mode 100644 index 0000000..b110a83 --- /dev/null +++ b/data/day09/input.txt @@ -0,0 +1,2000 @@ +D 2 +U 1 +D 2 +R 2 +L 1 +U 2 +L 1 +U 2 +D 1 +R 1 +D 2 +R 1 +D 1 +U 2 +D 2 +R 1 +U 1 +R 1 +U 2 +R 1 +L 1 +U 2 +R 1 +L 2 +U 1 +R 1 +U 1 +R 1 +L 2 +U 2 +D 1 +U 1 +D 2 +L 1 +U 1 +L 1 +R 1 +D 1 +R 1 +D 1 +U 2 +D 1 +R 1 +U 1 +L 1 +U 2 +L 1 +D 1 +U 1 +D 1 +L 1 +U 2 +L 1 +D 2 +R 2 +L 1 +R 2 +D 1 +L 2 +D 2 +U 2 +R 1 +L 1 +D 2 +U 2 +L 1 +D 2 +U 1 +L 2 +R 2 +U 1 +D 1 +U 1 +D 1 +R 1 +D 1 +U 2 +D 1 +R 1 +D 1 +L 1 +D 1 +L 2 +U 2 +D 1 +R 1 +D 1 +L 1 +D 2 +R 2 +U 2 +D 1 +U 2 +D 1 +U 1 +L 1 +R 2 +D 2 +R 1 +D 2 +L 2 +D 2 +R 1 +L 1 +U 1 +D 2 +R 2 +U 2 +R 2 +L 1 +R 1 +L 3 +U 3 +L 3 +D 2 +U 1 +D 1 +U 2 +D 1 +R 1 +D 1 +R 2 +D 3 +U 1 +L 2 +U 1 +D 2 +R 1 +D 1 +L 2 +R 2 +U 1 +L 2 +D 2 +L 1 +U 2 +D 3 +L 1 +U 1 +R 2 +U 3 +D 1 +L 3 +U 1 +L 3 +D 1 +R 2 +L 3 +U 2 +L 2 +U 1 +L 1 +R 3 +D 3 +L 1 +R 2 +D 3 +R 2 +L 3 +D 1 +U 2 +R 3 +U 2 +R 3 +L 2 +U 1 +L 1 +D 3 +U 1 +D 1 +U 2 +D 3 +U 3 +R 1 +U 2 +L 1 +D 1 +L 2 +U 1 +D 1 +L 1 +R 3 +U 3 +L 3 +D 3 +L 2 +D 1 +U 1 +L 1 +U 3 +L 1 +D 3 +R 1 +L 1 +R 2 +U 1 +R 2 +U 3 +R 1 +D 3 +L 3 +U 2 +L 3 +R 1 +D 2 +U 3 +R 3 +D 3 +U 1 +R 3 +D 2 +R 3 +U 1 +D 1 +U 3 +R 1 +L 1 +U 2 +L 1 +U 1 +L 1 +R 1 +D 1 +R 3 +D 4 +L 2 +R 4 +U 3 +D 1 +R 4 +L 4 +R 1 +D 2 +U 3 +R 2 +D 2 +U 3 +R 4 +L 2 +D 3 +L 4 +D 4 +U 4 +R 2 +U 1 +L 3 +D 4 +U 2 +R 1 +L 3 +D 3 +R 4 +D 2 +R 2 +D 4 +U 4 +L 4 +D 4 +R 2 +D 2 +U 3 +D 3 +R 3 +L 2 +D 2 +L 2 +U 3 +L 4 +U 2 +R 4 +D 4 +L 3 +R 1 +U 1 +R 2 +L 1 +D 1 +U 2 +D 3 +L 4 +U 3 +L 1 +U 3 +R 2 +U 3 +R 1 +U 1 +R 2 +U 2 +R 1 +D 4 +U 4 +L 2 +U 2 +D 4 +U 1 +R 4 +L 4 +D 4 +U 3 +D 4 +L 4 +U 3 +L 1 +R 4 +L 3 +D 3 +U 1 +R 4 +D 3 +U 4 +L 2 +U 4 +D 3 +R 2 +D 3 +U 4 +R 4 +L 4 +R 3 +U 1 +R 4 +D 1 +L 3 +U 3 +L 3 +D 1 +L 4 +R 2 +U 1 +L 3 +R 2 +U 4 +L 1 +U 5 +R 2 +L 2 +U 2 +L 2 +R 4 +D 4 +L 5 +D 1 +R 4 +U 5 +L 1 +D 4 +U 1 +L 4 +U 3 +L 1 +R 3 +D 1 +R 2 +L 5 +U 3 +L 5 +U 4 +D 3 +L 5 +D 2 +R 4 +U 2 +L 1 +R 4 +L 5 +R 3 +L 1 +U 2 +L 4 +D 1 +R 2 +L 5 +U 3 +D 2 +R 5 +L 4 +D 2 +R 3 +D 2 +R 4 +D 3 +U 1 +D 1 +U 4 +D 2 +L 2 +R 1 +U 5 +D 5 +U 3 +R 2 +U 3 +L 5 +R 1 +U 3 +L 4 +R 2 +U 3 +D 1 +U 2 +D 2 +L 5 +R 5 +D 3 +L 1 +R 3 +U 2 +D 5 +U 1 +D 5 +R 3 +U 1 +L 5 +R 1 +D 4 +L 4 +D 1 +U 2 +L 4 +R 5 +U 5 +L 4 +D 2 +R 5 +U 1 +L 5 +D 1 +L 1 +U 5 +R 1 +L 2 +R 5 +L 5 +R 2 +L 1 +D 2 +U 1 +L 3 +R 1 +U 5 +D 1 +U 1 +L 5 +U 6 +R 6 +U 5 +D 5 +R 3 +U 1 +R 1 +L 6 +R 6 +D 5 +R 6 +D 4 +L 3 +R 6 +U 5 +D 6 +L 2 +R 1 +D 5 +R 3 +D 2 +L 1 +R 5 +U 5 +D 4 +U 3 +R 5 +U 5 +R 3 +D 5 +R 3 +U 3 +R 2 +D 5 +L 6 +D 3 +U 3 +D 6 +R 5 +U 4 +L 4 +D 3 +U 6 +L 2 +R 1 +U 4 +D 1 +L 2 +U 1 +L 3 +D 4 +U 1 +L 5 +D 1 +R 2 +U 3 +L 1 +R 1 +U 1 +L 4 +U 6 +R 6 +D 3 +U 4 +R 2 +D 5 +L 6 +D 2 +R 4 +D 2 +U 5 +D 3 +U 2 +R 6 +L 5 +R 6 +U 1 +L 5 +U 1 +L 6 +U 1 +D 4 +R 3 +D 3 +L 1 +D 3 +R 2 +L 1 +R 3 +D 4 +L 6 +U 2 +D 5 +U 3 +R 6 +U 2 +R 6 +L 5 +R 1 +U 2 +R 3 +U 1 +R 6 +L 2 +U 6 +R 5 +U 1 +R 4 +L 1 +R 3 +U 3 +L 5 +D 7 +R 2 +D 4 +R 5 +L 3 +R 6 +U 7 +L 7 +U 6 +L 2 +D 2 +R 7 +D 7 +U 3 +R 1 +U 7 +L 2 +D 3 +L 5 +R 4 +U 7 +R 3 +L 7 +D 2 +R 7 +D 5 +L 7 +D 1 +U 7 +R 5 +U 4 +D 4 +U 4 +D 4 +U 1 +R 7 +L 3 +D 3 +U 2 +L 3 +U 1 +D 7 +L 6 +R 3 +U 6 +D 1 +R 6 +D 1 +R 1 +D 7 +U 4 +R 1 +L 4 +U 3 +L 7 +R 2 +D 2 +L 6 +U 2 +R 2 +U 7 +R 5 +L 6 +R 5 +D 1 +R 4 +U 2 +L 1 +D 4 +U 5 +R 4 +D 7 +U 7 +R 1 +U 3 +R 4 +L 1 +R 6 +L 4 +U 4 +L 2 +U 3 +D 2 +L 2 +U 2 +L 6 +R 5 +D 7 +L 2 +U 5 +L 6 +R 7 +L 7 +D 2 +U 6 +D 3 +R 1 +U 1 +D 4 +L 7 +D 7 +U 5 +L 6 +D 1 +L 4 +D 1 +U 1 +L 5 +U 1 +R 5 +D 8 +R 7 +L 5 +U 3 +D 2 +R 2 +L 6 +R 1 +L 4 +R 8 +U 8 +L 5 +R 7 +D 7 +L 2 +R 5 +L 6 +D 2 +L 7 +U 3 +R 2 +D 3 +U 3 +L 6 +U 5 +D 3 +L 6 +U 5 +D 5 +L 1 +U 4 +L 8 +D 3 +L 3 +R 2 +U 6 +D 8 +U 7 +L 6 +D 2 +U 4 +D 1 +U 3 +L 6 +R 2 +D 2 +U 4 +R 8 +D 3 +R 6 +D 6 +U 1 +L 4 +U 3 +L 6 +D 8 +U 7 +D 5 +L 3 +U 4 +D 2 +R 7 +L 8 +U 1 +R 3 +D 5 +U 5 +D 6 +R 3 +L 2 +R 8 +L 3 +U 5 +L 3 +U 5 +L 7 +U 7 +L 2 +U 1 +L 5 +D 7 +U 7 +D 8 +R 2 +D 7 +U 4 +R 4 +U 6 +L 2 +U 8 +D 1 +U 1 +D 4 +L 4 +U 1 +L 5 +R 8 +U 5 +D 4 +R 2 +D 6 +L 1 +D 8 +U 4 +D 5 +L 8 +U 3 +L 5 +D 1 +U 3 +R 1 +D 7 +R 9 +U 8 +R 7 +L 3 +D 8 +U 9 +D 1 +U 7 +L 6 +U 4 +R 8 +U 1 +D 6 +R 3 +L 5 +D 3 +U 1 +L 3 +U 2 +L 3 +U 2 +R 7 +D 2 +R 7 +D 8 +R 1 +D 4 +R 1 +D 6 +R 8 +U 8 +L 2 +U 8 +L 5 +D 1 +U 7 +R 4 +L 9 +U 2 +L 3 +U 4 +L 2 +D 3 +L 4 +U 9 +D 2 +R 2 +U 9 +R 1 +L 4 +D 5 +R 9 +U 3 +L 3 +U 8 +R 5 +U 7 +D 5 +U 9 +R 3 +D 9 +R 1 +D 7 +R 3 +D 6 +L 6 +D 5 +U 9 +D 8 +U 4 +L 5 +R 6 +D 7 +R 6 +L 8 +R 3 +U 3 +R 9 +U 8 +R 6 +L 9 +U 2 +R 9 +L 8 +U 1 +R 9 +L 5 +D 5 +U 9 +L 6 +D 7 +U 3 +D 3 +R 4 +D 1 +L 4 +D 5 +L 4 +U 2 +R 9 +U 7 +L 4 +D 7 +U 9 +R 4 +D 7 +R 7 +D 4 +L 1 +D 2 +L 1 +U 7 +R 8 +D 2 +U 9 +D 6 +L 7 +R 5 +L 3 +R 5 +D 8 +L 3 +R 8 +L 6 +U 6 +L 6 +U 5 +R 7 +L 9 +U 1 +R 3 +D 7 +U 10 +D 1 +U 8 +D 8 +L 5 +U 6 +D 5 +U 9 +R 8 +D 8 +R 9 +D 2 +L 1 +D 8 +R 2 +D 6 +L 10 +R 1 +U 3 +L 8 +U 7 +R 7 +U 7 +D 6 +L 7 +U 3 +L 4 +R 9 +D 8 +U 4 +D 3 +L 8 +R 7 +U 1 +L 9 +D 10 +U 2 +L 5 +U 3 +L 4 +R 10 +L 2 +D 6 +L 6 +D 2 +U 5 +D 3 +R 9 +D 2 +U 1 +D 5 +U 9 +D 7 +R 2 +U 5 +R 4 +D 9 +U 6 +L 10 +D 3 +U 1 +L 1 +D 9 +U 2 +L 8 +U 3 +R 5 +U 7 +D 8 +R 5 +L 8 +U 9 +L 1 +D 5 +U 8 +R 4 +D 7 +U 4 +R 10 +U 9 +R 9 +U 7 +R 3 +U 10 +R 5 +U 7 +R 6 +U 10 +R 9 +U 8 +D 8 +L 1 +U 2 +D 1 +R 9 +U 10 +D 6 +L 3 +D 4 +R 11 +D 11 +R 7 +U 3 +L 3 +U 11 +D 11 +U 5 +R 9 +U 3 +R 4 +D 1 +U 11 +R 2 +L 7 +R 8 +L 2 +D 4 +U 4 +L 9 +R 10 +L 3 +R 7 +D 7 +L 9 +U 6 +L 5 +D 8 +U 4 +D 4 +L 4 +D 2 +U 8 +R 4 +D 4 +U 10 +D 5 +R 5 +D 5 +U 8 +D 2 +L 6 +U 8 +L 2 +D 8 +R 5 +D 5 +U 1 +D 1 +L 9 +R 7 +U 2 +L 7 +R 1 +L 1 +U 2 +R 10 +D 2 +U 8 +L 1 +R 6 +L 3 +R 4 +D 6 +L 2 +D 11 +R 8 +D 11 +L 3 +R 4 +L 10 +U 7 +L 9 +U 4 +L 8 +D 6 +U 8 +R 7 +L 5 +R 8 +L 4 +U 6 +R 5 +U 7 +D 3 +L 8 +U 2 +R 7 +D 3 +R 4 +D 11 +L 8 +U 6 +D 1 +R 11 +L 7 +D 4 +R 4 +L 4 +U 5 +L 8 +R 7 +U 8 +D 12 +R 9 +D 8 +R 7 +L 9 +R 2 +D 1 +L 7 +D 3 +L 1 +R 5 +U 1 +D 12 +R 4 +U 1 +D 4 +L 9 +U 10 +R 5 +D 11 +R 2 +L 3 +U 8 +R 5 +D 8 +U 12 +D 6 +R 2 +D 5 +R 12 +U 7 +L 2 +U 4 +D 5 +U 8 +R 12 +U 1 +L 11 +U 7 +D 10 +L 6 +D 6 +R 1 +L 6 +D 2 +U 5 +R 6 +D 8 +R 4 +L 7 +D 2 +L 7 +D 8 +U 10 +R 1 +U 6 +R 5 +L 4 +R 8 +D 9 +R 5 +U 11 +D 4 +U 11 +R 8 +L 8 +U 2 +R 11 +L 12 +U 7 +L 12 +U 10 +R 3 +D 11 +R 1 +L 8 +D 2 +L 5 +R 4 +U 3 +D 9 +R 8 +D 11 +L 12 +R 11 +L 4 +R 10 +D 6 +U 4 +R 6 +D 6 +U 9 +R 12 +U 5 +R 8 +L 10 +D 1 +U 7 +D 12 +L 3 +U 10 +D 2 +U 6 +D 12 +R 3 +U 2 +D 2 +U 3 +D 11 +R 2 +U 2 +D 9 +R 11 +D 4 +U 6 +R 11 +L 9 +R 10 +D 13 +L 2 +D 2 +L 4 +D 13 +R 7 +L 3 +U 8 +D 5 +R 7 +D 7 +U 13 +D 5 +U 5 +L 12 +D 9 +L 2 +D 6 +U 13 +R 2 +D 10 +L 9 +D 7 +R 2 +U 3 +D 2 +L 3 +R 9 +U 3 +L 12 +U 4 +R 1 +U 13 +R 4 +U 1 +D 10 +R 10 +D 10 +U 5 +L 7 +D 8 +R 1 +D 12 +L 13 +R 10 +D 6 +R 9 +U 4 +R 9 +U 1 +L 3 +R 3 +D 8 +U 6 +L 11 +R 8 +D 5 +U 2 +L 9 +R 7 +L 7 +D 8 +L 12 +R 12 +U 9 +D 9 +U 7 +D 10 +L 3 +R 3 +D 8 +L 11 +U 8 +D 7 +U 11 +L 4 +D 4 +R 3 +U 4 +R 6 +D 5 +U 5 +L 8 +U 4 +L 9 +U 6 +L 8 +D 3 +U 12 +D 5 +L 8 +D 11 +U 4 +R 12 +U 7 +L 5 +D 4 +R 4 +U 7 +R 9 +L 5 +U 2 +L 3 +D 2 +R 6 +U 2 +R 8 +D 10 +U 14 +L 3 +R 4 +U 10 +R 7 +L 11 +R 7 +U 4 +R 8 +L 14 +D 11 +U 12 +R 10 +L 8 +R 11 +L 4 +U 1 +L 2 +R 7 +U 13 +D 5 +U 2 +L 6 +D 7 +R 5 +U 4 +D 10 +U 5 +D 2 +R 9 +U 13 +L 10 +U 1 +R 10 +D 14 +L 5 +R 12 +L 7 +D 2 +L 2 +D 5 +R 4 +U 6 +D 7 +R 12 +U 9 +D 9 +R 6 +U 1 +D 14 +U 14 +D 14 +L 7 +R 10 +U 3 +D 2 +R 10 +L 14 +R 7 +D 5 +U 1 +L 8 +U 2 +D 3 +U 6 +L 11 +R 13 +L 10 +D 9 +U 5 +R 6 +U 2 +D 7 +U 5 +L 6 +R 8 +D 11 +R 14 +D 5 +R 10 +L 13 +R 1 +U 4 +L 9 +R 2 +D 1 +U 10 +D 6 +U 3 +R 13 +L 9 +R 2 +D 3 +R 14 +L 2 +R 14 +U 1 +R 7 +L 1 +U 6 +D 6 +R 10 +L 12 +D 10 +R 11 +D 13 +L 3 +R 2 +L 1 +R 10 +U 1 +L 7 +R 5 +D 6 +U 11 +L 8 +R 7 +D 10 +U 13 +R 12 +D 8 +L 7 +U 8 +R 14 +U 10 +L 6 +D 15 +R 8 +L 10 +U 13 +L 3 +U 13 +L 9 +R 4 +D 6 +R 12 +L 12 +R 4 +U 12 +D 6 +R 2 +L 11 +R 7 +D 1 +U 4 +R 14 +U 6 +D 1 +U 15 +D 14 +R 3 +D 14 +L 1 +R 9 +L 2 +D 11 +R 11 +D 10 +R 1 +L 9 +U 6 +R 8 +L 4 +R 9 +U 13 +D 15 +L 2 +D 2 +L 2 +D 6 +R 10 +U 10 +L 8 +D 11 +L 8 +R 10 +U 3 +R 7 +U 15 +R 11 +L 10 +U 2 +R 8 +L 8 +D 5 +R 11 +U 7 +L 13 +D 15 +U 4 +D 10 +R 11 +D 6 +L 2 +U 3 +R 2 +L 1 +D 14 +U 5 +L 14 +D 13 +R 12 +U 8 +R 1 +L 14 +U 6 +D 10 +R 3 +U 8 +L 2 +R 6 +D 10 +U 9 +L 2 +D 13 +L 13 +D 9 +L 10 +U 14 +R 11 +L 14 +U 10 +L 6 +D 14 +L 11 +R 4 +L 9 +U 3 +D 13 +L 5 +R 16 +U 3 +L 9 +D 6 +R 15 +U 6 +L 4 +R 10 +D 12 +R 4 +D 2 +U 11 +D 13 +R 6 +U 15 +R 14 +D 14 +U 8 +R 9 +L 5 +D 16 +U 9 +R 15 +D 13 +R 3 +L 2 +R 3 +U 14 +D 9 +U 2 +D 6 +U 9 +D 7 +L 13 +D 7 +L 5 +R 3 +U 2 +L 13 +R 9 +D 1 +L 16 +D 8 +R 12 +U 15 +R 4 +D 15 +L 12 +D 13 +R 4 +L 2 +U 5 +R 13 +L 15 +D 12 +L 3 +D 13 +L 5 +D 16 +L 11 +D 13 +U 1 +D 9 +L 10 +U 11 +D 12 +U 11 +D 14 +U 16 +D 14 +U 10 +R 7 +L 11 +R 14 +U 11 +R 5 +U 1 +D 16 +R 16 +L 9 +U 7 +D 7 +R 8 +D 7 +U 10 +L 7 +D 6 +U 4 +D 2 +L 3 +D 3 +L 2 +R 3 +L 9 +D 2 +R 12 +D 11 +U 11 +L 14 +U 4 +L 12 +R 13 +L 9 +D 11 +R 12 +L 15 +R 15 +L 15 +R 16 +U 17 +D 4 +L 9 +U 9 +D 17 +L 8 +U 15 +D 17 +U 9 +R 4 +U 6 +L 1 +D 7 +R 3 +D 11 +L 10 +R 1 +U 14 +D 13 +R 7 +L 8 +U 16 +L 16 +U 12 +D 3 +R 4 +D 8 +R 8 +D 1 +L 12 +R 16 +D 3 +R 7 +D 16 +U 11 +R 6 +D 13 +R 4 +L 3 +R 6 +U 1 +R 4 +D 4 +U 13 +L 7 +D 17 +R 4 +D 6 +L 1 +U 17 +L 16 +U 12 +L 11 +R 1 +L 11 +D 8 +U 15 +D 6 +L 5 +U 16 +R 6 +D 11 +L 17 +D 7 +L 1 +D 8 +L 16 +U 8 +R 4 +L 17 +D 2 +L 1 +U 16 +D 8 +L 17 +U 12 +D 4 +R 1 +D 12 +U 2 +L 11 +U 17 +L 3 +R 7 +L 10 +U 16 +R 8 +U 6 +L 3 +D 15 +L 11 +R 7 +U 14 +R 8 +L 9 +D 6 +L 3 +U 17 +R 1 +D 13 +U 15 +L 18 +U 11 +R 3 +U 16 +D 12 +R 1 +D 6 +L 17 +R 9 +L 6 +U 2 +D 2 +U 16 +D 12 +R 1 +U 17 +R 16 +D 12 +U 3 +D 11 +L 13 +U 11 +R 15 +U 13 +D 11 +U 8 +L 3 +D 1 +L 7 +R 9 +D 18 +R 17 +U 2 +L 16 +D 8 +L 14 +D 11 +R 4 +D 12 +U 5 +D 6 +U 2 +D 4 +L 1 +R 11 +D 3 +U 10 +L 1 +R 16 +U 10 +L 17 +D 5 +R 16 +U 18 +R 1 +D 16 +R 14 +D 11 +U 13 +D 13 +R 5 +L 9 +U 11 +R 18 +L 14 +U 14 +L 18 +R 15 +D 10 +U 10 +R 17 +U 12 +L 2 +D 11 +R 15 +U 3 +R 17 +L 1 +R 1 +U 1 +L 8 +U 15 +R 15 +L 12 +U 2 +R 1 +L 9 +R 3 +L 6 +R 18 +D 9 +R 12 +U 6 +L 17 +R 11 +D 8 +R 17 +D 12 +L 2 +R 9 +U 4 +D 17 +R 18 +D 12 +L 9 +R 16 +U 5 +R 1 +L 12 +R 9 +L 8 +U 8 +R 2 +U 9 +L 2 +D 18 +U 11 +L 17 +U 3 +L 11 +R 3 +L 5 +D 1 +R 4 +U 10 +D 18 +R 10 +D 10 +L 5 +R 7 +D 2 +R 2 +L 18 +U 4 +D 10 +U 16 +D 1 +L 2 +U 17 +D 5 +U 9 +R 13 +D 6 +R 14 +D 10 +L 15 +R 13 +L 6 +U 11 +R 6 +L 4 +R 19 +L 4 +D 13 +R 1 +L 9 +D 4 +R 12 +U 18 +D 3 +U 17 +R 19 +L 6 +R 6 +D 8 +R 12 +L 10 +R 3 +U 5 +L 2 +D 7 +L 9 +D 16 +L 16 +U 14 +L 12 +R 2 +L 17 +R 18 +D 12 +R 16 +D 19 +U 6 +D 19 +U 13 +R 4 +D 18 +L 14 +U 14 +D 12 +R 10 +L 13 +D 10 +U 10 +D 2 +U 18 +L 19 +R 15 +D 6 +L 1 +D 10 +R 7 +D 2 +R 19 +D 5 +U 19 +L 13 +U 17 +L 3 +R 19 +U 9 +L 7 +D 6 +R 12 +L 10 +R 9 +D 9 +U 13 +R 7 +L 1 +U 1 +D 17 \ No newline at end of file diff --git a/data/day10/example01.txt b/data/day10/example01.txt new file mode 100644 index 0000000..94cd0a8 --- /dev/null +++ b/data/day10/example01.txt @@ -0,0 +1,146 @@ +addx 15 +addx -11 +addx 6 +addx -3 +addx 5 +addx -1 +addx -8 +addx 13 +addx 4 +noop +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx -35 +addx 1 +addx 24 +addx -19 +addx 1 +addx 16 +addx -11 +noop +noop +addx 21 +addx -15 +noop +noop +addx -3 +addx 9 +addx 1 +addx -3 +addx 8 +addx 1 +addx 5 +noop +noop +noop +noop +noop +addx -36 +noop +addx 1 +addx 7 +noop +noop +noop +addx 2 +addx 6 +noop +noop +noop +noop +noop +addx 1 +noop +noop +addx 7 +addx 1 +noop +addx -13 +addx 13 +addx 7 +noop +addx 1 +addx -33 +noop +noop +noop +addx 2 +noop +noop +noop +addx 8 +noop +addx -1 +addx 2 +addx 1 +noop +addx 17 +addx -9 +addx 1 +addx 1 +addx -3 +addx 11 +noop +noop +addx 1 +noop +addx 1 +noop +noop +addx -13 +addx -19 +addx 1 +addx 3 +addx 26 +addx -30 +addx 12 +addx -1 +addx 3 +addx 1 +noop +noop +noop +addx -9 +addx 18 +addx 1 +addx 2 +noop +noop +addx 9 +noop +noop +noop +addx -1 +addx 2 +addx -37 +addx 1 +addx 3 +noop +addx 15 +addx -21 +addx 22 +addx -6 +addx 1 +noop +addx 2 +addx 1 +noop +addx -10 +noop +noop +addx 20 +addx 1 +addx 2 +addx 2 +addx -6 +addx -11 +noop +noop +noop \ No newline at end of file diff --git a/data/day10/expected01.txt b/data/day10/expected01.txt new file mode 100644 index 0000000..ecee815 --- /dev/null +++ b/data/day10/expected01.txt @@ -0,0 +1,6 @@ +## ## ## ## ## ## ## ## ## ## +### ### ### ### ### ### ### +#### #### #### #### #### +##### ##### ##### ##### +###### ###### ###### #### +####### ####### ####### \ No newline at end of file diff --git a/data/day10/input.txt b/data/day10/input.txt new file mode 100644 index 0000000..871fb66 --- /dev/null +++ b/data/day10/input.txt @@ -0,0 +1,143 @@ +noop +addx 26 +addx -21 +addx 2 +addx 3 +noop +noop +addx 23 +addx -17 +addx -1 +noop +noop +addx 7 +noop +addx 3 +addx 1 +noop +noop +addx 2 +noop +addx 7 +noop +addx -12 +addx 13 +addx -38 +addx 5 +addx 34 +addx -2 +addx -29 +addx 2 +addx 5 +addx 2 +addx 3 +addx -2 +addx -1 +addx 8 +addx 2 +addx 6 +addx -26 +addx 23 +addx -26 +addx 33 +addx 2 +addx -37 +addx -1 +addx 1 +noop +noop +noop +addx 5 +addx 5 +addx 3 +addx -2 +addx 2 +addx 5 +addx 5 +noop +noop +addx -2 +addx 4 +noop +noop +noop +addx 3 +noop +noop +addx 7 +addx -1 +addx -35 +addx -1 +addx 5 +addx 3 +noop +addx 4 +noop +noop +noop +noop +noop +addx 5 +addx 1 +noop +noop +noop +addx -7 +addx 12 +addx 2 +addx 7 +noop +addx -2 +noop +noop +addx 7 +addx 2 +addx -39 +noop +noop +addx 5 +addx 2 +addx -4 +addx 25 +addx -18 +addx 7 +noop +addx -2 +addx 5 +addx 2 +addx 6 +addx -5 +addx 2 +addx -22 +addx 29 +addx -21 +addx -7 +addx 31 +addx 2 +noop +addx -36 +addx 1 +addx 5 +noop +addx 1 +addx 4 +addx 5 +noop +noop +noop +addx 3 +noop +addx -13 +addx 15 +noop +addx 5 +noop +addx 1 +noop +addx 3 +addx 2 +addx 4 +addx 3 +noop +addx -3 +noop \ No newline at end of file diff --git a/data/day11/example01.txt b/data/day11/example01.txt new file mode 100644 index 0000000..c04eddb --- /dev/null +++ b/data/day11/example01.txt @@ -0,0 +1,27 @@ +Monkey 0: + Starting items: 79, 98 + Operation: new = old * 19 + Test: divisible by 23 + If true: throw to monkey 2 + If false: throw to monkey 3 + +Monkey 1: + Starting items: 54, 65, 75, 74 + Operation: new = old + 6 + Test: divisible by 19 + If true: throw to monkey 2 + If false: throw to monkey 0 + +Monkey 2: + Starting items: 79, 60, 97 + Operation: new = old * old + Test: divisible by 13 + If true: throw to monkey 1 + If false: throw to monkey 3 + +Monkey 3: + Starting items: 74 + Operation: new = old + 3 + Test: divisible by 17 + If true: throw to monkey 0 + If false: throw to monkey 1 \ No newline at end of file diff --git a/data/day11/input.txt b/data/day11/input.txt new file mode 100644 index 0000000..4060600 --- /dev/null +++ b/data/day11/input.txt @@ -0,0 +1,55 @@ +Monkey 0: + Starting items: 97, 81, 57, 57, 91, 61 + Operation: new = old * 7 + Test: divisible by 11 + If true: throw to monkey 5 + If false: throw to monkey 6 + +Monkey 1: + Starting items: 88, 62, 68, 90 + Operation: new = old * 17 + Test: divisible by 19 + If true: throw to monkey 4 + If false: throw to monkey 2 + +Monkey 2: + Starting items: 74, 87 + Operation: new = old + 2 + Test: divisible by 5 + If true: throw to monkey 7 + If false: throw to monkey 4 + +Monkey 3: + Starting items: 53, 81, 60, 87, 90, 99, 75 + Operation: new = old + 1 + Test: divisible by 2 + If true: throw to monkey 2 + If false: throw to monkey 1 + +Monkey 4: + Starting items: 57 + Operation: new = old + 6 + Test: divisible by 13 + If true: throw to monkey 7 + If false: throw to monkey 0 + +Monkey 5: + Starting items: 54, 84, 91, 55, 59, 72, 75, 70 + Operation: new = old * old + Test: divisible by 7 + If true: throw to monkey 6 + If false: throw to monkey 3 + +Monkey 6: + Starting items: 95, 79, 79, 68, 78 + Operation: new = old + 3 + Test: divisible by 3 + If true: throw to monkey 1 + If false: throw to monkey 3 + +Monkey 7: + Starting items: 61, 97, 67 + Operation: new = old + 4 + Test: divisible by 17 + If true: throw to monkey 0 + If false: throw to monkey 5 \ No newline at end of file diff --git a/data/day12/example01.txt b/data/day12/example01.txt new file mode 100644 index 0000000..433e0d2 --- /dev/null +++ b/data/day12/example01.txt @@ -0,0 +1,5 @@ +Sabqponm +abcryxxl +accszExk +acctuvwj +abdefghi \ No newline at end of file diff --git a/data/day12/input.txt b/data/day12/input.txt new file mode 100644 index 0000000..b226042 --- /dev/null +++ b/data/day12/input.txt @@ -0,0 +1,41 @@ +abcccaaaaaaccccccccaaaaaccccccaaaaaaccccccaaaaaaaacccaaaaaaaccaaaacccccccccccccccccccccccccaaaaaacccccccccccccccccccccccccccccaaaaaa +abcccaaaaaacccccccaaaaaaccccaaaaaaaacccccccaaaaaaaaaaaaaaaaccaaaaacccccccccccccccccccccccccaaaaaacccccccccccccccccccccccccccccaaaaaa +abccccaaaaacaaaccaaaaaaaacccaaaaaaaaacccccccaaaaaaaaaaaaaaaacaaaaaacccccccccaaacccccccccccaaaaaaaaccccccccccaaccccccccccccccccaaaaaa +abccccaaaaccaaaaaaaaaaaaacccaaaaaaaaaacccccaaaaaaaaaaaaaaaaaaacaaaacccccccccaaaacccccccccaaaaaaaaaacccccccccaaaccccccccccccccccccaaa +abcccccccccaaaaaacccaacccccccccaaacaaaccccccaacccccccaaaaaaaaacaacccccccccccaaaacccccccccaaaaaaaaaacccccccccaaaccacaaccccccccccccaaa +abcccccccccaaaaaacccaacccccccccaaacccccccccccccccccccaaaacaaaacccccccaacaaccaaaccccccccccaccaaaaacacccccccccaaaacaaaaccccccccccccaac +abccccccccccaaaaacccccccccccccccacccaaaacccccccccccccaaaacccccccccccccaaaacccccccccccaacccccaaaaccccccccjjjjaaaaaaaaaccccccccccccccc +abccccccccccaaaacccccccccccccccccccaaaaacccccccccccccaaaccccccccccccccaaaaacccccccccaaaaaacccaaccccccccjjjjjjkkaaaacccccccccaacccccc +abcccccaaccccccccccccccccccccccccccaaaaaacccccccccccccaacccccccccccccaaaaaaccccccccccaaaaaccccccccccccjjjjjjjkkkkaacccccaacaaacccccc +abccaaaacccccccccccccccccccccccccccaaaaaaccccccccccccccccccccccccccccaaaacaccccccccaaaaaaaccccaacccccjjjjoooookkkkkkkklllaaaaaaacccc +abccaaaaaacccccccccccccccccccccccccaaaaacccccccccccccccccccccccccccccccaaccccccccccaaaaaaaaccaaaaccccjjjoooooookkkkkkkllllaaaaaacccc +abcccaaaaacccccccccccccccccccccccccccaaaccccccccaaaacccccccccccccccccccccccccccccccaaaaaaaaccaaaaccccjjooooooooppkkppplllllaccaacccc +abccaaaaaccccccccccccaccccccccccccccccccccccccccaaaacccccccccccccccccccccccccccccccccaaacacccaaaacccijjooouuuuoppppppppplllccccccccc +abcccccaacccccccccccaaaaaaaaccccccccccccccccccccaaaaccccaaccccccccaaacccccccccccccaacaaccccccccccccciijoouuuuuuppppppppplllcccaccccc +abcccccccccccccccccccaaaaaaccccccccccccccccccccccaaccccaaaacccccccaaaaccccccccccaaaaaaccccccccccccciiiiootuuuuuupuuuvvpppllccccccccc +abcccccccccccccccccccaaaaaaccaaaaacccccccccccccccccccccaaaacccccccaaaaccccccccccaaaaaaccccccccccccciiinnotuuxxxuuuuvvvpppllccccccccc +abccccccccccccccacccaaaaaaaacaaaaaaacccccccccccccccccccaaaacccccccaaacccccaaaaccaaaaaccccaaccccccciiiinnnttxxxxuuyyyvvqqqllccccccccc +abcccccccccccaaaaccaaaaaaaaaaaaaaaaaaccaacccccccccccccccccccccccccccccccccaaaacccaaaaaccaaacccccciiinnnnnttxxxxxyyyyvvqqqllccccccccc +abaaaacccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccaaaacccaaaaaacaaaccccciiinnnnttttxxxxxyyyyvvqqmmmccccccccc +abaaaaccccccccaaaaacccaaaaacaaaaaacaaaaaaccccccccccccccccaaccccccccccccccccaacccccccaaaaaaaaaaciiinnnnttttxxxxxyyyyvvqqqmmmccccccccc +SbaaaacccccccaaaaaccccaaaaaccaaaaaaaaaaaccccccccccccccccaaacaacccccccccccccccccccccccaaaaaaaaachhhnnntttxxxEzzzzyyvvvqqqmmmccccccccc +abaaaacccccccaacaacccccaaaaaaaacaaaaaaaaaccccccccccccccccaaaaaccccccccccccccccccccccccaaaaaaacchhhnnntttxxxxxyyyyyyvvvqqmmmdddcccccc +abaaaacccccccccccccccccccaaaaaacaaaaaaaaaacccccccccccccaaaaaaccccccccaaaccccccccccccccaaaaaaccchhhnnntttxxxxywyyyyyyvvvqqmmmdddccccc +abaacccccccccccccccccccaaaaaaacccccaaaaaaacccccccccccccaaaaaaaacccccaaaacccccccccccccaaaaaaacaahhhmmmttttxxwwyyyyyyyvvvqqmmmdddccccc +abcccccccccccccccccccccaaaaaaacaaccaaacccccccccccccccccaacaaaaacccccaaaacccccccccccccaaacaaaaaahhhmmmmtsssswwyywwwwvvvvqqqmmdddccccc +abcccccccccccccccaaaccccaaaaaaaaaacaaccaaccccccccccccccccaaacaccccccaaaacccccccccccccccccaaaaacahhhmmmmmsssswwywwwwwvvrrqqmmdddccccc +abcccccccccccccaaaaaaccccaaaaaaaaaccaaaacccccccccccccccccaacccccccccccccccccccccccaaaccccaaaaaaahhhhhmmmmssswwwwwrrrrrrrrmmmmddccccc +abcccccccccccccaaaaaaccccaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccccaaaaaacccccaaaaachhhhhmmmmsswwwwrrrrrrrrrkkmdddccccc +abccccccccccccccaaaaaccccccaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccccaaaaaaccccaaaaacccchhggmmmssswwrrrrrkkkkkkkkdddacccc +abccaaaacccccccaaaaacccccccccaaaaaacaaaaacccccccccccccccccccccccccccccccccccccccaaaaaaccccaacaaaccccggggmmsssssrrlkkkkkkkkkdddaccccc +abccaaaacccccccaaaaacccccccccaaaaaaccccaacccccccccccccccccccccccccccccccccccccccaaaaaccccccccaaccccccgggmllssssrllkkkkkkkeeeddaccccc +abccaaaacccccccaaacccccccccccaaaaaacccccccccccccccccccaacccccccccccccccccccccccaaaaaacccccccccccccccccggllllssslllkkeeeeeeeeeaaacccc +abcccaaccccccccaaacaaaccccccaaaaaaaaaaacccccccccccccaaaaaacccccccccccccccccccccaaacaaacccccaacccccccccggglllllllllfeeeeeeeeaaaaacccc +abccccccccccaaaaaaaaaaccccccccccccaccaaaccacccccccccaaaaaaccccaaccaacccaaccccccaaaaaaacccccaaccccccccccggglllllllfffeeecccaaaaaacccc +abccccccccccaaaaaaaaacccccccccccccccaaaaaaaccccccccccaaaaaccccaaaaaacccaaaaaaccaaaaaacccaaaaaaaacccccccggggllllfffffccccccaacccccccc +abcccccccccccaaaaaaacccccccccccccccccaaaaaaccaacccccaaaaaccccccaaaaacccaaaaaacaaaaaaacccaaaaaaaaccccccccgggffffffffccccccccccccccccc +abccccccccccccaaaaaaacccccccccccccaaaaaaaaacaaaaccccaaaaacaaaaaaaaaacaaaaaaacaaaaaaaaaccccaaaacccccccccccggffffffacccccccccccccccaaa +abccccccccccccaaaaaaacaaccccccccccaaaaaaaaacaaaacccccaaaaaaaaaaaaaaaaaaaaaaacaaaaaaaaaacccaaaaacccccccccccaffffaaaaccccccccccccccaaa +abccccccccccccaaacaaaaaacccccccccccaaaaaaaacaaaaaaaaaaaaaaaaaaaaaaaaacaaaaaaacccaaacaaaccaaaaaacccccccccccccccccaaaccccccccccccccaaa +abccccccccccccaaccaaaaaccccccccccccccaaaaaaaccccaaaaaaaaaaaaccccaacccccaaaaaacccaaaccccccaaccaacccccccccccccccccaaacccccccccccaaaaaa +abcccccccccccccccaaaaaaaaccccccccccccaacccacccccccaaaaaaaaaaccccaacccccaaccccccccaccccccccccccccccccccccccccccccccccccccccccccaaaaaa \ No newline at end of file diff --git a/data/day13/example01.txt b/data/day13/example01.txt new file mode 100644 index 0000000..27c8912 --- /dev/null +++ b/data/day13/example01.txt @@ -0,0 +1,23 @@ +[1,1,3,1,1] +[1,1,5,1,1] + +[[1],[2,3,4]] +[[1],4] + +[9] +[[8,7,6]] + +[[4,4],4,4] +[[4,4],4,4,4] + +[7,7,7,7] +[7,7,7] + +[] +[3] + +[[[]]] +[[]] + +[1,[2,[3,[4,[5,6,7]]]],8,9] +[1,[2,[3,[4,[5,6,0]]]],8,9] \ No newline at end of file diff --git a/data/day13/input.txt b/data/day13/input.txt new file mode 100644 index 0000000..3624788 --- /dev/null +++ b/data/day13/input.txt @@ -0,0 +1,449 @@ +[[1,4,7,4,8],[],[8,0,7,[],[]]] +[[10,[5,[0,2,5,3,3],[9,7,9],6],7,9,[2,9,[],4,0]],[8]] + +[[7],[7],[[[3,4,6],1,[1,2,4],[7,5,3,5,2]],[[1,3,2,7],10,[9,9,0,2]],[9],[1,[10,4,7],[5,2,1],[10,9,4,3]],[7,[8,9,9,4],[]]],[],[]] +[[8,[[]],[7,3],4],[[[2,3]],10,[[4],[3,9,4],[0,6,5],1,3]],[],[]] + +[[5],[[[],[8,0,4],1],[],2,6,10]] +[[[[3,0],[7,10,9]],[9,4,3]]] + +[[2,10,[1,[],5],[[1],[3,0,9,7,2],[6]],[[],[7,0,2]]],[[[0,10]]]] +[[3,[[],[5,0,2],2],7,[[0,2,9],2,[4]]],[3,[[4,5]],[[10,2,5,1],[1],9,[3,3,7,7,10],9]],[]] + +[[[[],9,7,[2,8,2,1],[6,3,7,6]],8]] +[[[[9,8,2],[10],[9,0,3],0,[3,5,0]]],[]] + +[[[9,10,[1,0,6],[1,2]],[[],[9,5,3],[7,3,10,1],0,0],5,10,[]],[]] +[[5,6,1,6],[8,6,5,[7,0,5,[0,4,3,6,6],[8,7,8,5]]],[[[1,2],9,1],10,4,3,[5,[5,10,9,9],7,0,[2,3]]],[[[1,5],[0],0],3,[[]]]] + +[[0,[[4,6,4,8]],3,[10]],[],[6,8,6],[8,[3,[7,7,10,6,5]],[0,8,[7],[],5]],[1,[3,[4,4,8,3,8],3,[1,9,8,3,10],[0,5,8]]]] +[[0,[],10]] + +[[[[2,4],[5],10,1],[3,6,3],8,0,9],[9,1,9],[[[1],[2,0,7],[10,2],6,[10,9]],[[10],[1,0,3],5,[1,7],[]],3]] +[[9,6,3],[[6,[8,10,3],2,[6,1],10],1],[]] + +[[8,[],[10]],[]] +[[[[8,5,6,6,5],1,[10]],[]],[],[],[7],[2,2]] + +[[9,3]] +[[0,[1],6,[10,0,6],7],[7,[1,[4,3,10],[],[6,6]],5,[9],7],[7,[[6,2,7,2,5],9,8,7,[9]]],[5]] + +[[9,9,[[10]],[8,[7]]],[8,5,7,[[6,1,8],[9,5],[],10,8],[8,[10],[],[5,3,2]]]] +[[[9,9,6],1,0,9,[[0],[8],2,0]],[[9,5],[[],[9]],3,[[0],9,3,0,8],10],[[[4],[8,2],[2,0,3]],3,6,[[3,8]],4]] + +[[4,3,[[10,8,3,1,10],[9]]]] +[[[6,[0],[3,4],[0]],[],[6,2,[],1],[[],1,[1,4,3,7],9,4]],[0,[[0],[9,2]],1]] + +[[[[8,4],[7,8,6,10,1],[]],[[2,8,10,4,5],[0,8],7,[1,5],4],8,[1]],[],[]] +[[3,[4,[3,3,4]]],[[],1,9,[0]],[[],[[6,9,1],[10,2,3,2,8],3],3,5]] + +[[[[0,3,7],3,[4,0],[6,2,0],4],1,[[3,4,7],8,[1]],2]] +[[0,6,[[6,9,6],9,[0],[2,10]],4]] + +[[2,[],6,[[8,10],7,7]],[[[1,2,3,8,3]]],[]] +[[[],9,9],[9],[[2,4,8,[7]],[1],1,9]] + +[[1],[[[],[6,7,6,8],0,[2,3]]]] +[[[[9,7,2]],3,[8],7,[[3,6,10]]],[[],10]] + +[[3,6,[5]],[5]] +[[],[0,[[6,2],[]],3,4,[[6,1,6,10],8,[5,8],5]],[1,4],[[[8]]],[4,3,[[7,2],9,[],3,3],[5,0,[9,0],10],[[7,8,2],3,3,3]]] + +[[[7,[]],[]]] +[[[[0,1,2],[3,7,6,5,9],8],[7]],[[[8,6,3,6,2],[7,0,2,5,3],[1,2,1],8]],[7,[2,[0,0,4],[4,1,8],5,[7]],4,2,5]] + +[[9,1,10,[[5],[],[2,1,4],5,0]],[10,[2,9,1],[10,[0,4],9,4],9],[[4,3,6,[0,3,10,6]],[4,[2]],9],[],[]] +[[6,[4,[2]],[],10],[[[1,1,5],[5,6,6],7],[2],[[10],[],10],[[3,3],1,5,[1,1,9,4,3]],0],[8,[],[[]],10,1],[1,[],[[7,4,2],1,0,9],2],[[0,9],[[2],9,[9,1,8]],1,[4,1,9,[3]],3]] + +[[[3,[],[9,7]],[[3,0,2,6],2,[0,9,1],[6],[7,4,0,7]],[3,[],[10,1,6,2],0],5,3],[3,[]],[],[2,[[],10,4],[6,[5]]],[]] +[[],[],[[7,[1,1],4,7,[6]],[4],[7,3,6,[4,9,8,3],7],[4,8]]] + +[[4,3,8,2,6],[[[8,1]]],[[6,3],[3],[8,[7,7,4,2]]],[8,[6,[10,10,3],0,8],[],7,[10]],[8,0,7,4]] +[[5,10],[],[6],[]] + +[[2,6]] +[[1,7]] + +[[4,0,[[],[2,6,3],10]],[[],[1]]] +[[3,10,2],[[10,[7],[7],5],[[0,4],[9,1,8,8]],1,[9],1]] + +[[3],[[[2,1,5,0]],8,7,[[5,7]],[[],2,8]],[[9,[3,5,2,8]],[[4,7,9],[8,7,4]],[3,10],3,7],[[]]] +[[5,[],3],[8,[[2,8,10],[],9,[7,9,7],[3,10,4,1,10]],6],[]] + +[7,7,4,8,0] +[7,7,4,8] + +[[],[5],[4,0,[[1]],[[],[0,1,0],[8]],[[9,8],6,[],[8,8,6,1,4]]]] +[[],[0,[]]] + +[[[],10],[[[2,7,7,0],[5,5,1,8],0,[]]],[[[5,6,4],0,3,[10,3,2,10,2]],7,9,4,6],[[[],[6],[3,7,4,6,3],4,7]],[4,[]]] +[[8]] + +[[],[],[[10,[0,7],9,[3,6],[]]],[5,[1,2,[1],[9,2,3,4]],[[6,7,7,1,10],7],[8],[[10,8],[2,3,5,2,5],[9,9,9,10,7],[8,2]]]] +[[7],[],[[[1],9,10,[9,1,1,4],6]],[[[7,4],0,[10,1],9],0,[[],[1,6,6],[]]],[]] + +[[],[10,3,1],[[[9,5,10,10,5],[4,1],5,6,10],0]] +[[4,[[8,9,0],0,[0,10,2,4],7,5],[8,2,3,5],0],[],[3,[[0,1,2,10]]],[6,[],[[],0,3,[4,4,4,3,4]],0],[[[5],5,3],[[],[3],4,0,[3,3,6]],4,[0,6,[]],[5,5,7]]] + +[[[],4,[1,0,0,7],10],[],[],[7,[8,[4,0,10]],[[4,5,4,7],6,8,1,[7,10]]],[[[3,6,0],1,8,2],[],10,0,1]] +[[4,7,5],[6,[[0,9],[1]],[[2],[8,1,2]],8,[9,[7],7,1,[7,0,6,4]]]] + +[[6,[[6,10,4,3,8],5]],[],[[[8,9,6],[5,9,8,4,4],[3,10,3]],10,9],[[8,3,[6,2,5,1],[1,7,1]],[5,[3,8,3],[2,3,7,5],8],[[7,5,2],[5],[4,1,10],9]],[5,1,7]] +[[],[5,[6,[4,0,8,10,0],[9,6]]],[[],6,[[3]]],[]] + +[[2,[]]] +[[[]]] + +[[[8,[3,9,1,0,2],[],[1,10,9,10],[1,10,3,2,7]],6,[[8,9,0],[8,1],4]],[[5,[],[3,2,3,2,2]],[],[0,[10],7,3],5],[[10]]] +[[0,10,[3,3,7,[1,1,5],5],1],[[1,5,5,7,6],[],[],7],[],[1,[9,8,[4],2]],[[],[0,0,[3],[1]],[5,[9,10,1,1],8,1]]] + +[[10,0,3],[2],[1],[[[9,9,3,10]],[],2]] +[[[0,3,[9,1,1,5],6,[]],[8,10,5,1,[8,2,4,0,8]],[[4,9,7,7,4],[7,7,7,5,5],7],[[],[2,10,4,6,2],[6],[6,4,2,2]],2]] + +[[[[9,1,2,6,9],[8,4,5]],0]] +[[9,[[6],[],2,7,0],1,[[8,0,9],[5,1,1],10,8]],[3,[[10,3,7,0,1]]],[1,[[],2,3,[5,5],0],[[8,6,1,9,2],10,[],4]],[]] + +[[0,3,6,4]] +[[7,3,[5,[5,7],[9,3,7],0],[[7,7,10,2,3]],[10,[0,9,0,5]]],[],[]] + +[[1,1,[2,[1]],[[8,2,7]]],[7],[[3],8],[[[7,1,7],[1,6,5,0,2],7,[4,3],4],1,8,2,[[8,9]]]] +[[[10,[],5]],[[3],[6,5,5,[1,2]],8,3]] + +[[6,0,8,6],[2,5,[[10,8,6,0],6,[3,10,7]],[4,[3,9],[4,6,3]],9],[]] +[[10,[],[[10,5,6,1,10],5,[9,1,1,8]],[[2,8,8,6,5],10,4,[5,0,2,6,1],5]]] + +[[[[2,8,9,4],[8,9],[7,0],[10]],4,9],[[0,[3,2,4,0]],2,[[0,0],[10,9,1],6,[5,6,3,8]]]] +[[[6,10],[9,9],[1],[4,9,6,[3,6],[]]],[6,2,6,[[7,1,4],1,7,[4]],5],[[[10,4,6]],[4]],[5,[[5]],[[7,1,7,0,1],3,2,7,[4,5,7,8]],[10,8]],[[4,[]]]] + +[[10]] +[[[7,[]],[10,[0,1,4,6,3],0]]] + +[[5],[8]] +[[[3],10,[[7,1,1,5,6],0,4,2],8,[[6,3],[10,2,9],[3,10,3,3],1]]] + +[[],[]] +[[2,1]] + +[[],[5,8,2],[[[1,0]],4,[[2,5],8,[6,0],10]],[[[3,8,10,7],8,8,1],1,9]] +[[0,4,[[7],0,[],[5,8,7,8,4]],[2,0],4],[2,5,5,[]],[],[0,[[3,3],0,[10,1,0],5]],[]] + +[[[[4,2,8],10],[7],0],[7,[10]],[[6,[],[1,5,8],[2,1,1],8]],[[]],[[[5,5,7]],[[]],[[],[],8],7]] +[[],[[[6,7,6,1,2],4,9,[7]],7,10,4],[[],4,1]] + +[[6],[],[8],[[[6],2,9],[[],1,1,[],[2,5,3]],5,8,[[8,3],7,[],[2,10,7,0],9]]] +[[8,[[9,9,1,8],6,[6,8],1,7]],[[0,[5,7,8],6,8,6],0,2,4,[[10,6,10,6,8],[8,3,7,5],[0],2,[0]]],[],[[10],[[],[8,9,3,8,2],[6,3,2,1],[7,10,8,7,1]],[7]],[2]] + +[[10,[[4,6],[9,10,8,6,6],[10,6,0],1,0]],[[3],10,[]],[[1],2],[1,[1,[3,1,2],1,10],[[9,1],[2,4,0,10,4]],[0,8,[5,1,9,9,7],3],5],[[[10,4,3,3]],[[3,6,1],1],[[4,2,10,7,3],8,[2,6,0],[6]]]] +[[8],[[[9,6,0]],[],[],10],[[[],6,[7],[2,2,9,6]],0,10,1,1],[[[1,7,0],6,10,6,2],3,[]],[2,6,6,[]]] + +[[3,[[2,10,3,2,4],7],2,[[],7]],[],[],[[[1,4,9,3],[],7,[0,7]],0,1,3,4]] +[[4,3,[4,1,[]],[[6,5,1],10,4]]] + +[[7],[0,[3,[0,9],10],[[9,5],9,7],1,[0,[0,8,9,3,7],2]],[2],[4],[[[8],4,[7,4],8],9,7,[2,5,8]]] +[[10,[[0,3],[9]]]] + +[[[[],9,[8,8,9,10,9]],[],10,10],[10,[],0]] +[[0,[],6,3,[[],[]]],[7,[8]],[[[4,3,3,2,9],10,4,[]],5],[]] + +[[3]] +[[[3],[],[6,[7,9],[1,7,3],[8]],2,0]] + +[[[[5,8],[5],[7,5,7,6,4]],[[],1,[0,10,3,0,1]]],[]] +[[[[6,10],[1,4],[7]]]] + +[[[[6],[9,8,5]],4,[[7,6,3,2],[7,3,6,3],9,[6,4,0,5]],4],[5,[],9,[[],[6,0,9,9],4]],[[],1]] +[[[[],6,3],3,[]],[0,1,[8,[1,9,10]],0],[9,[[3,0,6,0,3],0,0],[2,[8,9,3,10]],7,[[6,3,8,9,4],[2]]],[[],0],[6,[6,[4,3]],[],4,[10,9,[2,7,9,8,3],8,[]]]] + +[[5,8,[[1,8],4,[8],[10],0],8],[],[[9,9,10,1],2,[1,8,[4,7,4,1,0],[8],6]],[[],[7,0,[4,2,7,5]],10,[]]] +[[0,[5,6],10],[[[2,9,5,1],4,[5,7,6,3,10]],8,[4,[2,4,3],9],5],[],[[9,[4],[9,5]]]] + +[[[],7,[[3],8,5,[8,7]]],[[5,4,3,8,[]],7,[[]],[],[4,[6,7],7,3]]] +[[7,2,4,[8,[0,3],1,6,[]]],[],[9,6,[8,9,3,0],[]]] + +[[[],7],[0,10,[0,[9,9],8,7,[8,3,0]]]] +[[],[[[1,5],[10,4]],[[2,1,4,1],[3,2],4,[7,9,10,5,4]],7,[]]] + +[[10,4]] +[[[[8,3,10]]],[1,[[1,8,9,9,6],[6,5,2,6,3],5],8],[6,8],[10,1,[[4,4,8],7]]] + +[[[[]]],[],[9,8]] +[[0,1,8],[1,[5,1,[10,2,4,2,5],8,8],6,2],[4,[4,[3],3,[2,0,3],7],6,[]],[[[8,5,3],10,[1,2,6,6]],4]] + +[[7,[2]],[]] +[[[[1,5,10,0,2],1,[8,2,8,2],[5,10,8,2]],4,2,[2],2],[[6,[],[],[]],[[]],9],[9,3],[8,2]] + +[[],[1],[2,[[0],8,9],5,[[10,0,3,5,2],7,2,[9,2,2],[9]],[[7],[]]]] +[[6],[[[5,4],[],[4,0]],[[5,3,0],7,[8,2,10,7],[0,8,5],5],[],[0,5],5],[[10,7],4,5,9]] + +[[7,10,3,2],[1]] +[[10,[[7,7,9,4,9]],2,[3,8,[],[],10]],[7,[[2,4],7,0,[9]],4,[[10]]]] + +[[4,[2,[],[1],10],4],[[[7],[4,6],[9,1,10,0,4],3,[2]],[[7,4]]],[[4,4,5,0]],[5,1,[[3,0,8,10]]],[3,[[2],[3,8],[],[2,6]],3,[10,[7,3],9],3]] +[[[[2,0],[2,4,10,10,9],2],7,10,[],8]] + +[[[[6,4,5,2,9]],1,[3],[6,[10,1],9,[10,10],[3,1,6,10]],5],[[]],[],[8,10,2,10,[[10,8,6],2,[],[10,9,1,10],1]]] +[[[],2],[[[7,2,2,9,7],7,2,4],[[2],3,5]]] + +[[[],[[8,5,7],[0,0,10,7]],10],[[0,10]],[[8,6],4,[4],[[],[1,0,4],[5,2,0,3,8],[9,2,5,8]]]] +[[0,[[7,7]],0,[],4]] + +[[5,0],[3,[],6,[3,10,0]]] +[[[],[4,[10,3,10],[9,4,5,0]],[],[[10,7,6,6,0],1],[10,10,7,[],[1,0,4,0,7]]],[[1],[],[],[4]],[8,[],8,[[2,6,8],2,[2]],10],[[[8,3,3,5,4],[5,8,2,8,9]],4,6],[3,2]] + +[[1]] +[[9,1,2,6,3]] + +[[8],[9,[[]],9,[[0,5,8,1],7,0,3,[0,4,1,6]],[[3,8,9,6,3],[],[8,7,4,6,10],[8,7,0]]],[[[5],[9,7,6],[8,3,2],1],8,6,[10,[6,6]],9],[[],10,[7,[6,4,3],[],6,4]],[[3],[[6]],[6,[],[],[9],[10]],9,6]] +[[[],2,[0,[3,5],4,9],3,[]]] + +[[[[1],7],[[],4,[4,8,8],[10,7,3,2],[]],[]],[7,1,6,0,[3,0,[1,0,2,6,5],[2,2,9,6,2],[6,9,6,7,10]]]] +[[[[3,2,8,9,3],[6,2,4,7],[2,7],[7,2,9,2],[3,4]],[]],[[3,2],[1,2,[9,10,3],[7],[8,8,7,3]],[0],[[4],10,5,3],[6,[],[0],[]]]] + +[[[5,[],[],5],[0,[1,0,5,1,3],10]],[8,[4,10,3,[]],5,1]] +[[2,[[8,7],5],5,0],[],[[],5],[[],2,[[9],5,[7,2,1,0],[6,2,8]],[[2,4,2],8,[9,7,8,0,7]],10]] + +[[4,7,[2,3,9],3]] +[[[[0],[0,1],7],[1,[]],4],[],[[[5,8,5,8],8,[10,6,8,4,8],[10,3,7,5],10],[]],[[[1,8,6],[5],[9,2,6,3,2]],[1,[9,10,3,2,7],[2,10],10,4],7]] + +[[[],[10],[4,[2],6,[8,1],7],8],[[9,[9,8,9,10,10],7,[8,0,9,7,4],[]],[[7,2],[5,5,9,1,3],[4,8,6],[2,10],5],3,[4,[5,6],8,[]]],[8,[7,[9,1],[1,8,6,2,7]]],[8,[],[],[[0,1],8,2],0]] +[[8,[[1,6,3],1,[6,7,0],10],10],[9,[[7,6],9,[7,6,10],9],6],[10,[[6,7],9,4,5],7,0,1],[[3],[6,1,[3,4],[0,0,5],[]]],[[[0]],10,5,[[7],[],7,[7,7,3]]]] + +[[[],7,5,1],[4],[4,[[3],0,6,[9,0,3,3,0],6],9,[[9,9,2,5]]]] +[[[[10,0,7],8],[[6,9,1],3,[2,1,1,0],10],4,10]] + +[[[[10,9,4,1,9],[1,4],0],3,[9,[2,5,0,9],9,8]],[7,[8,[1],3,[6,1,7,1,5],4],[[10,2],[9,4,7,4],[10,2]]],[10,6,0],[[[10],[],[2,3,8,6,8],2,6],[[5,3,2]],9,8,1],[[4],[[2,5,3,4],1],[2,7,4,6,[4,6]]]] +[[10,[[4,0,7,7,2],[7],[6,8]],9,7],[6]] + +[[1,4,6],[],[[0,[7,6,10],[8]],[9],[[3,4],10,[9,6,5],3],[[3]]],[8,[],1,9]] +[[[5]],[[2],[[1,3,6]],0,6,10],[4,1,[10,4,10,3],2],[6,6]] + +[[],[6,1,[[5,8]],2]] +[[7,[9,[],[5]],[6,[8,1],3],8,[6,[10,0,1],3,[6],[]]],[8,1,3,[4,[5,3,5],[],[3,10],8],0]] + +[[[3],3],[3,[10,[2,6,4,7],[10,4,4,6]],[3,10],[0,8,6,2,[10,10,5,9,8]]],[[4,2,5,[],2],[[],[9,0,8],[2,4,5,0]],[[6,10,6],9],[4,4,9,4],10],[[]],[[[7]],7,[6,[6],8],8,[[8,8]]]] +[[0,[7,[3,10,4],2]],[0,1,[[1,1],[6,0,10],2,4,[10,3]],5,4],[[[3,3,2,4],[3],3,[0,2,8,5,3]]]] + +[[[],10,[4,2]],[]] +[[[4,[10,6,3,1],[0,2,10,2,3]],9,[4,1,7,9,8]],[[[5],2,2,[8,8]],7],[[],[[],[8,4,3,7],[],[2,9,4,4],[]],[[7,10,10,9,8],3,2,6],2],[3,[[4,8,8],[10,5],1,3,8]],[[[0,7,2,4,3],[],[2,10],4,4],[],1]] + +[[3,9,10],[[[4,7,4],[10,2,4,7,7],[8]],[[3,1,5,4,4]]]] +[[5,7,5,[[7,9,1]],[[9,7,1,4,2],1]],[10,10,5,[[0,0,7,8],3]],[[3],[],[1,[1,2]],[]],[[],0,6]] + +[[[[0,6,9],[9,9],7],2,3],[[[8,9,7,7],8,5,[6]],4,5]] +[[1],[10,[[]],8,[[0,2],[2,10,4],[3],[]]],[],[[1,5,[4,1,0]],[],[5,[8,2]],[5]],[0,9,[],6,7]] + +[[9,4,[9,4]]] +[[[[2],8,8,[10,1],[6]]],[[[],[8,9],6],[]],[[1,[8],5,2,10],7]] + +[[[[3,1,2,2],0,[7,1]],[],2,9,2],[[6,[4,0,0],[4,4,6,3,2],[1,10,5,10,8],5],[4,[3,8,5,3],3,[2,6,0,4,0]],[[8,5,4,6]],3],[[[10,1,5],[],[2,3,9],[4,8]],3,[3,[],8,1]],[[[7,5,2,8,7],[4,8],[10,10],3,0],[[3],[6,9,9,5,9],4],6,5,[[2,10],[10,4],1,[10,8]]]] +[[],[9,8,[0,[9]],8,[4,[3,5]]],[]] + +[[[2,1]],[],[[],2],[[[1,7,2,9,7],3,6,[5,0,7]],6],[]] +[[2,[6,[5,4,8,0],8,6],[[8,7,5,3],[5,1,3,6],[1],2,[0,1]]],[[[9]],[[],[],2],5,6,7]] + +[[[0],[9,[]]]] +[[],[1,[7,[10],[10,6],7,[7,8,9,3]],[[8],[0],[],[9]]],[[5],[6,8]],[[8,[0,4,0],5,[2,1,10,6],[]],6,6,[[],3]],[[[2,2,7,3,3]],3,3]] + +[[9,4,[[5,10],[],[],[9,8,10,0,8],[1,6,8]],8,6],[[[0,1,9],2,[9,8,2,7]],0],[]] +[[10,5,2],[[7,[8,4]],7,4],[],[6],[4]] + +[[[6,[8],[1,9,6,9],[10,1],6],[[7,3,3],2,7,[1,0,3,2,4],[7]],4],[9,[[7,5,10,4],6,4],[[4,2,9],[7,2],[0]],2]] +[[[]],[3,[[0],[9],[],[],10]],[3,10],[7,10,[],[0,7,2,8],[3,[8,6]]]] + +[[6],[],[5,[6]]] +[[],[[9,[1,1]]],[3,0,[],2,[]]] + +[[[6,10,[]],[1,[7,4],2],6,4,[[2,8,5],5,6,[1,6,9],[9,3,4,10]]],[]] +[[],[7,[5,[9,1,5,6],[1,4,10],[2,4,10,9,3]]]] + +[[],[10,0,7,0],[2]] +[[10,[[6,2,8]]],[[1,9,[]],3,4],[1,[5],1,1]] + +[[[5,7,4,1,[9,8,7,7]],[10]],[4,7,[[4,9,9],1,6,[10,4],7],[7,10,7,5],9]] +[[],[8,0],[2,[8,3,8,1]],[[[6,8,6]],[2,7,7],[[8],5,9]],[[1,[5,8,5,7]],[9],[0,8,4,7,[]],[9,5]]] + +[[[6,6],1,10,9,10]] +[[6,6,7,[[8,7,6],3,[4],10],[8,6,[0,3,9,3,0],[5,9,10]]],[8,4,[5,[9,5,2,2],[8],4,10],2,[[10,6,6,0],[6,6,7,3],6,0,[1,6,6]]],[[],[],4],[4,[1,[2,3,1,7],3],8]] + +[] +[[1,[[4,2,6,0,1],[8,6]],[6,[4,5,9,3],10,[0,7]],8],[6,3,7,[[10,7,10,4,7],[3,0,5,10,10],10]],[[]]] + +[[5,5,[[],0,[3,10],[6,3]],[9,[10,0,6,8,8]]],[[[1,3,1],8]],[],[]] +[[6,5,[8,0,9],9,2],[10,[3]]] + +[[[],8]] +[[8,0],[[6],[4,8,[9,2,2,0],[5],[]],2],[[4,3,[9,3,5,4,5]],[[1,6,0,8],5]],[4,10,[[9,8,5,10,5],2,[4,9,9,1],[10,8,9,2],[4,10,5]],[9,1]]] + +[[[[5],[3,7],9]],[[7,10,[7,6,0],[1,0,5,6],[3,5,2,4,0]],[[2,0,7,1,7],1,[7,0,4,10],6],0,[9]],[3,[3,5,[10,8],[5,9,9]],2],[6,[],1,3]] +[[[[5,4]],[[1,9,0,5,8],4,[2,6,2,0],9]],[9,[0,7,[2,8,10,6]],[[10],[4,2,4,3,4],0],4],[],[2]] + +[[[2,[2,10,4,4,6],10,6,[3,8,3,0,2]],[[3,0,2,0],[7,1],[1,0]]]] +[[[8,1,1,[9,2]],[[9,7,2],[],7,4,3],[1,[3],[2,3],3,4],[[1],[6,7,3,2]],7],[6],[[[2,5,4,4],[],4,9,4],[[10,8,4,0],8,[1,1,6,2,6],[6,8,5,10,0],7]]] + +[[],[3],[[2,5,9],2,9,[[5,9],[2,3]]],[[3,1,[3,10,4,3,9],[2,0,6]],[[6,3],6,[9,7,9,7,10],[8,7,8,0,6]],7,[],[7]]] +[[[6,8,4,[4]]]] + +[[2,7,[],[6,[1]]],[[[8,0],[4,8],[]],[0,[2,2,1,3],[8,0,3,7,4],[7,7,4,5,3],2],1,[7,[3,9],[5,6,8,8,5],[7,2,9]]],[[0,9,4,4],[9,4]]] +[[[10,[7],5,[]],10,10,4],[1,[[],0,[10,10,7],[7,10,1,4],10],4,[0,[8,9,1,8,8],3]],[]] + +[[[3],0],[[5,1,[4,10,4],9]],[6,5,[[7,1,8],2,8,[0],5]],[[[5]],[5,[7,10],[1,9],2,[9]],2],[]] +[[[[10,5,0,1]],8,[]],[[1],[7]]] + +[[3,6,4,[7,[6,9,4,9,9],8],[10]],[0,9,3,[[],8,[10,7,1,8],7,[1,2,5,7,7]]],[4],[[4],[],7],[[[2,9,1,5,6]],8,3]] +[[[5,[7,1,4,8,9]],[[2,8,8,2,10],7,[8,9],9],10,[[3,1,0,3,3],[3,7,10,0,8]],[5,2,[3],[2,3]]],[],[5,8]] + +[[[],6,10,0]] +[[[[8],9,4,[],[]],[5,10,1,[1,4,10,9,0]],2,9,1]] + +[[]] +[[[3,4]],[[8,0,[1,9,6,7]],[9,[10,2,6,3],2,[3,6,7,8,6]],[]]] + +[[[[10],0,6,3,[4,4,3,5,10]],[2,[6,4,7]]],[]] +[[5,8,[0,[0,5],[0,8],6,[]],[8]],[[[5],[7,5,8,9],[2],[]]],[6],[[8,[9,8]],[[0,10,10],[7,6,6,2,10],[10],[]],[[2]],[4,[],[2,1],[7],4],[0,7]]] + +[[0],[],[5],[4,7]] +[[3],[6,6],[5,0],[4]] + +[[[]],[9,[[1,7,8]]]] +[[[4],7,8],[[10,3]],[10,[[7,6,10,10],7,7],[7,9,1],3,2]] + +[[],[[[],[2,5,7,6,1],8,7,9],[4,[7,5],[10]],[[7,3,1,1,3],0,1]],[10,10,[4]],[],[8,[[9,4]],[8,[3,2],[7,4],0],5,8]] +[[4,[],2],[],[],[0,4]] + +[[[4,1,9,[8,6],8],[6]],[2],[2],[[[2,3],[8,7,8,1,5],4,0,2],[[3],[1,9,10,6],3,[1,1,4,1]],[[9,5,6],[10,4,10,4],1],4],[7]] +[[[1],8,[[8]],[[6,10,5],7,7,9],[3]],[5],[[8,9],[[10,1,2],[4,8],5,6],4],[[4],8,[5],[[4,9,3,2,5],8,[],[0,4,9,4],0],9]] + +[[[],[[],7,[]],8,1],[[[0,9,5,10,0],7,9,[1,5]],7,2],[[6,[4,2,0,0,1],6,2,[1,8]]],[[0,[]],5],[0,[],[[],[8,0,6],[9],2,10]]] +[[5,[[3,3,9],[3,1],[]],[9,[1,8,7,9],0,2,4]]] + +[[0],[4,9,[[],8,[2]]],[[6,4,1,[],2],8,[[9,1,2],3,7,[1,1,2]],4,[2,[10,7,7,9,0],2,10]]] +[[10,[[0,2,5,10],8,[10],1,[8]]],[[[7],[4,8],[7],[9,10],9],0],[[[0,6],[8,3,3],[5,10,1,1,1],7],[4],[10],8,6]] + +[[0,4],[4],[5,[3,[3,7,3]],[[4,1,0,7]],9],[4,[[5,6],[7],0,6,[7,6,7,0,5]]]] +[[],[1],[5,[[2,1,6]],1,[7,[8,7,6,1,4],2,[4,5]],1],[],[[9]]] + +[[1,8],[6],[[[9],[9],[2,10,8],[2,3,1,0],[6,7]],0,2,[1]],[]] +[[[1,3,8],[[4,5,4],2,[8,8,7,9],[6,8]],9],[[1,8,[4,9,9,8,8]]],[6,[1,[5,8,3,1,4],[],[9],[6,5,2]]]] + +[[],[[],[[9]]],[]] +[[5,[4,4,[1,3,8,5],10,0],0,[],7],[]] + +[[5]] +[[[],5,3,10,3],[[1],[5,[0],[],10,8],[[10,6,3,2,6],[5,10,1,7],2,[7]]],[8,[[2,3,9,2,9]],10,10]] + +[[[2,1,9],0,[10,5,6],[0]],[[4],9,[5,3]]] +[[7,2,0,9],[[1,3],4,3,7],[9],[],[5,[[8,3],7,[2,0,1,2]],9]] + +[[[5,3],5],[],[8,[1,10,[10,1]],[6,0],[[1,2,0,2],4,0],[]],[[10,6,7,1],3,[8],[[3,10,9,0],7,[5,1],3,8]],[[7,6],10]] +[[2,8],[7,3],[[1,[6,2],7],5],[[6,[1,10,4],[0,5],[4,5]],10,10],[]] + +[[2],[[[],[],[0,8,6,2,1],6,[5]],[[1,4,5,5,7],1,2],1]] +[[],[[[8,5,9,8,7],5,[7,7,10]]],[8]] + +[[[],7],[[[9,10,6,6],[6,10,1,9,4]],[1,9,0,[0,4,10],10],4],[[[5,7],6,3,6],[[9],[2,3,5],0],2],[[[10,10]],[0,[8],[6,6],5],[[8,8],5,7],[8],2],[9,9,[[]]]] +[[[8],[[9,0,6,6,5],8],[4,[7],[4,6,6],[3,3],10],8,[]],[[[8,2]]],[9,4,[[4]],[[1,5],[0],[1,6,1],[]],0],[0,3,9,[6,7,1,0,[]]]] + +[[3,[],[[1],[4],7,[1,2,0,6,5],[5]],6],[4,9,1,1],[5,[[4,2]],[]],[2],[8,2]] +[[[8,[7,9,8,0,4],[2,3,3],[],[9,5,6]],3,[2,[2,1,3,10,10],9,[4,9,2,2],8],2],[3,0,0,5,[4,[2,1],6,[2,3,9,1,8]]],[9,0,7],[8,5,1,[],9]] + +[[],[[[2],[0,4],6],4,[[1,8],8]],[[],10]] +[[[],[5],10,[[10,5,0,7],[],1,[],7]],[3,[]],[],[2,[[8],9],[3,0,1],[[3,5],[9,2]]],[]] + +[[5,[[10],6,[3]],7],[3,10,[1]],[[[7,6,8,8,10],[5,5,2],[7,1,2],[]]],[3,9,[0,3]],[7]] +[[2,[[6]],10,[9,[8],[],[1,10,4,4,9],[5]],[8]],[10],[],[3,[10,3],2,[[4,10,5,6,7],[5,7,7],6]],[10,7]] + +[[[[],[5,2,9],10]],[[6,[],[2,0]],[[0,9,0],7,[]],[[9,3]],[]]] +[[10,[[1,1,8],7,3],[[8,6,10],4,0],9,6],[],[7,[],[3,[9,1,5],[10,4,1,8,1],0],[[3,2,1],4],[[8,10]]]] + +[[],[],[[[10,3,7,10]],0,0,6,[[6,3,4,8]]],[9,[[],[2,10]]],[[8,[],[3,10,5,8,10],6,[9,6]],6]] +[[[],[9,3,[10,7],[6],7],[[6,10,10],[3],[10,7,0,5,0],7],6],[[[7,9,4,9,4],3,7,[7,1,7,4]],8,[9,7,[6,2,3,9,1]]],[4,[],3]] + +[[5,5,9],[[5,[8,9,7,2],[5,7],[5,1,4,3,4],4],[0,[],3],1,3,3],[5,5],[[2,[2,9,4],[1,3,4],[5,6,9],[1,2]],9]] +[[[[8,6,9,9]],[[8,3,7,9],[10,1,0,3],8,[0,3,10,7]],[4,5,[3,4,3,2,6]],[[10]],9],[[[]],2],[8,10]] + +[[[0,1,[7]],8,[[3],4,0],[[]]],[[0,1],[[5],10,1,[4,6,0,10,0],[5,6,10,10]],4,[1,[1,8],[4,9,9,10,5]],[8,3,1,[],9]],[6],[[],[[2],9,[7,1,6,5],[9],[10,9]]],[[[0],[9,3]],[2,5,[8,1,7],[]],[],[],5]] +[[2,[[4,3,5,5,2],4,[9,6],2,9],9,[3,2]],[[]],[[[10,9],[2],10,4,4],3,[[3,7,3],[0,2,1,9,0]],[9,6,5]]] + +[[],[[[8,7,10],6,[3,8],5],[2,1,[1,5,4,3]],9,[[],[],[8,3],6,[10]],2],[2,0,[[],3,2,5,[0,7,8]]],[[[5,5,6],[1,9],[6],[10],7],8,[[8,7,3],0]]] +[[8,[],5,0],[],[10,[[],9,4,[7]],[]],[9],[4,10,0]] + +[[5,9],[[[10,8,5,6],5,9,7,[]],[],[0]],[[1,4]],[[[5,9,4,1],[10,7,5,9],[6],0,7],[4,8],4,10,4],[6,9,[8],1]] +[[],[9,6,[6],7,0],[6]] + +[[3,1,3,5,[]]] +[[3,[[0,8,2,10,3],[5,1,3,4,0],10,9],0,6,1],[6],[0,3,8,[2,7]],[10,2,5,[7,10],[2,3,[],[2]]]] + +[[3,8,5,[7,[5,2],4],[3]],[[1,[1,0,5,1],7],4],[[8],[[1,5,9,0,9],2,[]],7,[[4],[7],[0,10,2,5,5],8],[10,[1]]],[[10],[7,[5],5,[4,3,9],[]]]] +[[],[[6],[2]],[[2,[1,9],[8,3],1],10,0],[[10,1,[5],7,2],[4,3],[[6,4,9,1,4]]],[[5,[2,6,9],[4,7,9,6,3],[1,6,0,6,0]]]] + +[[[[0],7,[0]],[],[10,3,[5,9],6,[2,7,10]]],[],[[[5,7,3,3],[3]],0,[7,9],[7,4,[9],8,8],[7]],[10,7,10,0,5]] +[[[],[],[[],8,0,[8]],0,[]],[6,3,9,5,9],[],[[],7,7,[4],[[0],[6,3,6,0,9],9]]] + +[[5,2,[[8,0,0],8,8]]] +[[6],[[4,[9,4],[3,1]],[6,2,0,[3]],0,7]] + +[[],[[],[]],[],[10,[],[[7,4,1,3,5],9,0],[],7],[]] +[[[8,7]],[1,[0,[9],2,[]],9],[[[10,3,9,5,8],[],[]],7,[9,[3,0,3,8,9]],[[2,1],[7,2,0,2,9]]],[]] + +[[[],[[7,7],[4]],6,[[],7],[]],[[[3,0,0,1],[1,9,10,4,10]],2,[10,[],[5,0],3],1,[[7,6,2],5,10,0,[7,8]]],[]] +[[[1,[2,0,9,0,8]],[[],1,0],6,[5]],[[],10,[8,[1,2]],[]]] + +[[2,7,[[3,4,4,2],1,[9],5,3],[[2],8,[3,7,5],9]],[7],[[3,4,[],[]]],[4,[],5,[10,5,[4,4,5,0],1]]] +[[[0],2,7],[]] + +[[2],[[2,7],5,[[9],10,0],[[1,5,2,7],3,10,6,[6]],[[2,0,9,4],6]],[[[10,8,7,4,9],[10],[5,1,4],9],[[10,3,10],[],[5,9,9],[10,3,2,5,9]],[[0,7,3,10],8,3,[9,7],[3,4,9,8]],7],[[1,10,6,0],5,6]] +[[[]],[[0,2,[4,1,9]],[],5,[[10,4,5,4,2],[10,3,0,1,3]]],[3,0]] + +[[8,4,4,[[],[7,9,2,8],8,6],8],[[[9],[10]],[[5,7,5],[],[4,6,0,5,5]]]] +[[2,[[6,6,0,2,5],6,[7,1,7,9],7],[[9,3],5,[9,2,7],[9,8,3],0],2],[[[3,8,3],[3,1,5],[0,0,0,6],[5,5,4,1],[3]],[0],6,[0,[]]]] + +[[2,[3],[]],[2,[[10,4,6,10,5],3,4,8]],[[[],5,1,10],[9,[8,0,2,5],9,8,[6,10,5,9,1]],[3]]] +[[4,[[7,10],9],[7,1]],[[[8],1,9,[1,10,5]],[[9]],[[4,1,3]],10,[4,2,[9],[7,8,2,1,1],5]],[[[],0,6,2],[2,[],1,[2,9,0,8,7]],[[8]],4],[[[6,3],[],5,8,[10,3,5]],6,0,6],[[[1,1,0],0,[10]]]] + +[[3,[[1,1,9],9,[6],8,4],[]]] +[[],[6,[7,1],[6,10,[0,2,1,3],[],[8,4]],10,2],[[[6,10]],8,6,[10,[0,2,3],1]],[0,5,4,6,[]]] + +[[9,[[1,8,3,2],[3],[8,2,9,3],[6,8,7]]]] +[[],[6,[[10,1,9]]],[10],[6,[[4]],[[2,8,10],[5,10],[2,8,3]],0],[7,5,1,[[7,10,3,1,9]],[[0,1,0,0,3],[]]]] + +[[1,7],[0,[],2]] +[[[[2,0,0,5,1],3,[5,6]]]] + +[[8,[[0,8],2,3],10,[[6,5,0,1,6],10,8,[10,4,5]],5],[1,4,2,6,[[9,7,10,7,9],2,5]],[5,[[6,0,4,8]],7,[[2,3,2,7]]],[[4,[],7,7,5],[[],10,[],8],[[1,6,5],2,0,8,[]],[[0,9,7,1,3],9,[7,2,9,8]],[[],[1,7],2,2]],[1,8]] +[[10,[]],[9,[]],[[4,[4],3],7,[[4,2,4],10]],[[5,[5,5,4,3],4,6,[6]],9,[[5,8,7,4,6],[],10,2,[1]]],[]] + +[[6,9],[0,2,[[9],0,[8,10,9,7]],7,[4,4,2,[]]],[[9],[7,[8,4],[8,2],0],[[4,2],[5],[4,6],[0,6]],[5]],[[[9,2],8,[0],9,[1,9,4]],[[7,0,2,5,5],1,[6,8,2],6,7]],[[10],9,3,5,[]]] +[[[[4],0],[],[5,9,[9,3,4,9,7],8],3,9],[7,8,2,3,0],[4,[5,[7,2,3,9],6,[0,4,0,3],8]]] + +[[[[2,4,0,1],[2,10,7,6,1],7,[7,1,10],7],[],[[8],1,[9,6,5,2],4,[4]]],[[4,1,[5,9,7],[4],6],4,3,[[8,2,8,8,9],[7,0,10]]],[[]],[[],[[0,0,1,3],5],9],[1]] +[[[[]],[9],[[6,5,0,0],[8,8,9,2],[10,10,10,8,2],[7,2,4,0,0]]],[8,[3,[6,1,5,7,4],5,0,4],3]] + +[[4,[]],[9,2,[0],[3,2,[2,6,7,5,6]]],[[[3],[],[4,5,9,0,2],[5,3,0,1],[2,7,7]],10,9,3,[[3,4,6,8,10],3,1,2]],[]] +[[[8,[3,2,2],10,10,[8,7,8]],[[7,2,2],[1,8,2,7],[0,2,1,2,7]],[8],7],[10,0]] + +[[[[6,6,3,4,0],5],[6,7,9],5,[[4,9,1],[9,2],0,6],[7]],[7]] +[[[0]]] + +[[[],8,[]],[1],[]] +[[6,[]],[3,4],[[7,[9],3,4,7],[10,[3,10],0,3,[1,9]],[0,5,[6,3,6,7],2,9]]] + +[7,6,8,6] +[7,6,8,6,4] + +[[[5,[10],[6,2,2],3],7,[],[],7],[[2,[7,5,3],1,7,10],6,[[],4,9],[6,[4,8]],1],[],[[[2,4,3,6,3],[0,10,8],[2,2,7]],6,[[5,7],2,5,10],[9,[0,8,0,9,7]]]] +[[10],[3,[[3,5,5],[5,2,10],[2,9,10],[1,3,3,0,7],1],[[7,2,4,3],1,[0,8]]],[5,0,[[3],5,8],[[],9,[4,10,1],7]]] + +[[9,[[],1,1,4],[10,4,[5,3,1,6],10,[]],0,0],[8,7,4],[6,[3,[9,9,6,3,3],[10,0]],[[],4,[10,0,9],1]],[[4,[6,3],[0,10,8,5,5],1,7],[[]],2,3,1]] +[[[3,[3,8],[4,9,3,8,1]]],[],[[3,[],[4,3,9],8],4,1,2,2],[],[[[5,3,8,7]]]] + +[[[[8,9,3,6,4],[9,10,3],[],6],[4,1,[0,2,3]],4,[[9,6],10,9,0]],[[[9,8,1,0],[8,9,5,4,6]]],[[]],[[3],6,[2,6,8,[2,1,3,3,6],[4,7,5,1]]],[2]] +[[],[10],[[4],10,[8]]] + +[[3,[[9,9],[4,4,5,8,3],0,4],9,[[1,9,0],4,1,0,8]]] +[[2,2,[6,4],[],7],[0],[10,8]] + +[[[[]],6,[[3,8,6,3,9]],9,6],[5,[[0,9,8,7],1,8],9,7],[4,[2,[4,8,3,6]],5,[0,8,[3,9,6,3,10]],7]] +[[0,[],8]] + +[[[[6,8],[10,1,5,1,5]],[[]],[[4,0,10,6],4,[10,5,1],9],[10],[10,[],[10,2],[10,4,3,7],[3]]],[10,2,[10,[],8],[8,[1,5,0,7,5],[],[4,9,10]],9]] +[[[],10,[],8,10],[[[],7,0,[10,0,1,10,4]],5],[8,[4,3],[[10,10,9,1],[3,0,6]],4],[[]],[]] \ No newline at end of file diff --git a/data/day14/example01.txt b/data/day14/example01.txt new file mode 100644 index 0000000..1926028 --- /dev/null +++ b/data/day14/example01.txt @@ -0,0 +1,2 @@ +498,4 -> 498,6 -> 496,6 +503,4 -> 502,4 -> 502,9 -> 494,9 \ No newline at end of file diff --git a/data/day14/input.txt b/data/day14/input.txt new file mode 100644 index 0000000..880a895 --- /dev/null +++ b/data/day14/input.txt @@ -0,0 +1,179 @@ +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +568,139 -> 573,139 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +534,78 -> 539,78 +513,78 -> 518,78 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +553,133 -> 558,133 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +511,53 -> 515,53 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +543,144 -> 543,145 -> 560,145 -> 560,144 +522,69 -> 527,69 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +560,133 -> 565,133 +561,139 -> 566,139 +518,94 -> 518,95 -> 532,95 -> 532,94 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +517,53 -> 521,53 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +518,94 -> 518,95 -> 532,95 -> 532,94 +520,78 -> 525,78 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +546,114 -> 546,115 -> 554,115 -> 554,114 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +522,63 -> 527,63 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +564,136 -> 569,136 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +534,111 -> 534,112 -> 549,112 -> 549,111 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +526,72 -> 531,72 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +533,66 -> 538,66 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +527,78 -> 532,78 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +550,136 -> 555,136 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +556,130 -> 561,130 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +547,139 -> 552,139 +505,57 -> 509,57 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +567,133 -> 572,133 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +520,55 -> 524,55 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +543,144 -> 543,145 -> 560,145 -> 560,144 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +575,139 -> 580,139 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +511,57 -> 515,57 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +514,55 -> 518,55 +546,114 -> 546,115 -> 554,115 -> 554,114 +557,136 -> 562,136 +571,136 -> 576,136 +546,114 -> 546,115 -> 554,115 -> 554,114 +497,13 -> 497,17 -> 489,17 -> 489,22 -> 502,22 -> 502,17 -> 501,17 -> 501,13 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +525,60 -> 530,60 +559,127 -> 564,127 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +517,81 -> 517,84 -> 509,84 -> 509,92 -> 524,92 -> 524,84 -> 522,84 -> 522,81 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +529,63 -> 534,63 +526,66 -> 531,66 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +508,55 -> 512,55 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +534,111 -> 534,112 -> 549,112 -> 549,111 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +516,75 -> 521,75 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +523,75 -> 528,75 +523,57 -> 527,57 +519,66 -> 524,66 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +554,139 -> 559,139 +543,144 -> 543,145 -> 560,145 -> 560,144 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +553,118 -> 553,120 -> 549,120 -> 549,124 -> 561,124 -> 561,120 -> 557,120 -> 557,118 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +514,51 -> 518,51 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +517,57 -> 521,57 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +518,94 -> 518,95 -> 532,95 -> 532,94 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +496,35 -> 496,29 -> 496,35 -> 498,35 -> 498,26 -> 498,35 -> 500,35 -> 500,25 -> 500,35 -> 502,35 -> 502,34 -> 502,35 -> 504,35 -> 504,31 -> 504,35 -> 506,35 -> 506,33 -> 506,35 -> 508,35 -> 508,25 -> 508,35 +530,75 -> 535,75 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +519,72 -> 524,72 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +563,130 -> 568,130 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +531,98 -> 531,102 -> 526,102 -> 526,109 -> 540,109 -> 540,102 -> 535,102 -> 535,98 +534,111 -> 534,112 -> 549,112 -> 549,111 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +561,171 -> 561,162 -> 561,171 -> 563,171 -> 563,168 -> 563,171 -> 565,171 -> 565,163 -> 565,171 -> 567,171 -> 567,163 -> 567,171 -> 569,171 -> 569,161 -> 569,171 -> 571,171 -> 571,170 -> 571,171 -> 573,171 -> 573,166 -> 573,171 -> 575,171 -> 575,161 -> 575,171 -> 577,171 -> 577,165 -> 577,171 +501,48 -> 501,44 -> 501,48 -> 503,48 -> 503,39 -> 503,48 -> 505,48 -> 505,39 -> 505,48 -> 507,48 -> 507,41 -> 507,48 -> 509,48 -> 509,41 -> 509,48 -> 511,48 -> 511,47 -> 511,48 -> 513,48 -> 513,47 -> 513,48 -> 515,48 -> 515,43 -> 515,48 +551,158 -> 551,154 -> 551,158 -> 553,158 -> 553,156 -> 553,158 -> 555,158 -> 555,152 -> 555,158 -> 557,158 -> 557,149 -> 557,158 -> 559,158 -> 559,156 -> 559,158 -> 561,158 -> 561,152 -> 561,158 -> 563,158 -> 563,155 -> 563,158 -> 565,158 -> 565,153 -> 565,158 -> 567,158 -> 567,155 -> 567,158 -> 569,158 -> 569,149 -> 569,158 \ No newline at end of file diff --git a/data/day15/example01.txt b/data/day15/example01.txt new file mode 100644 index 0000000..6d6c325 --- /dev/null +++ b/data/day15/example01.txt @@ -0,0 +1,15 @@ +10 +Sensor at x=2, y=18: closest beacon is at x=-2, y=15 +Sensor at x=9, y=16: closest beacon is at x=10, y=16 +Sensor at x=13, y=2: closest beacon is at x=15, y=3 +Sensor at x=12, y=14: closest beacon is at x=10, y=16 +Sensor at x=10, y=20: closest beacon is at x=10, y=16 +Sensor at x=14, y=17: closest beacon is at x=10, y=16 +Sensor at x=8, y=7: closest beacon is at x=2, y=10 +Sensor at x=2, y=0: closest beacon is at x=2, y=10 +Sensor at x=0, y=11: closest beacon is at x=2, y=10 +Sensor at x=20, y=14: closest beacon is at x=25, y=17 +Sensor at x=17, y=20: closest beacon is at x=21, y=22 +Sensor at x=16, y=7: closest beacon is at x=15, y=3 +Sensor at x=14, y=3: closest beacon is at x=15, y=3 +Sensor at x=20, y=1: closest beacon is at x=15, y=3 \ No newline at end of file diff --git a/data/day15/input.txt b/data/day15/input.txt new file mode 100644 index 0000000..e1e288b --- /dev/null +++ b/data/day15/input.txt @@ -0,0 +1,32 @@ +2000000 +Sensor at x=3859432, y=2304903: closest beacon is at x=3677247, y=3140958 +Sensor at x=2488890, y=2695345: closest beacon is at x=1934788, y=2667279 +Sensor at x=3901948, y=701878: closest beacon is at x=4095477, y=368031 +Sensor at x=2422190, y=1775708: closest beacon is at x=1765036, y=2000000 +Sensor at x=2703846, y=3282799: closest beacon is at x=2121069, y=3230302 +Sensor at x=172003, y=2579074: closest beacon is at x=-77667, y=3197309 +Sensor at x=1813149, y=1311283: closest beacon is at x=1765036, y=2000000 +Sensor at x=1704453, y=2468117: closest beacon is at x=1934788, y=2667279 +Sensor at x=1927725, y=2976002: closest beacon is at x=1934788, y=2667279 +Sensor at x=3176646, y=1254463: closest beacon is at x=2946873, y=2167634 +Sensor at x=2149510, y=3722117: closest beacon is at x=2121069, y=3230302 +Sensor at x=3804434, y=251015: closest beacon is at x=4095477, y=368031 +Sensor at x=2613561, y=3932220: closest beacon is at x=2121069, y=3230302 +Sensor at x=3997794, y=3291220: closest beacon is at x=3677247, y=3140958 +Sensor at x=98328, y=3675176: closest beacon is at x=-77667, y=3197309 +Sensor at x=2006541, y=2259601: closest beacon is at x=1934788, y=2667279 +Sensor at x=663904, y=122919: closest beacon is at x=1618552, y=-433244 +Sensor at x=1116472, y=3349728: closest beacon is at x=2121069, y=3230302 +Sensor at x=2810797, y=2300748: closest beacon is at x=2946873, y=2167634 +Sensor at x=1760767, y=2024355: closest beacon is at x=1765036, y=2000000 +Sensor at x=3098487, y=2529092: closest beacon is at x=2946873, y=2167634 +Sensor at x=1716839, y=634872: closest beacon is at x=1618552, y=-433244 +Sensor at x=9323, y=979154: closest beacon is at x=-245599, y=778791 +Sensor at x=1737623, y=2032367: closest beacon is at x=1765036, y=2000000 +Sensor at x=26695, y=3049071: closest beacon is at x=-77667, y=3197309 +Sensor at x=3691492, y=3766350: closest beacon is at x=3677247, y=3140958 +Sensor at x=730556, y=1657010: closest beacon is at x=1765036, y=2000000 +Sensor at x=506169, y=3958647: closest beacon is at x=-77667, y=3197309 +Sensor at x=2728744, y=23398: closest beacon is at x=1618552, y=-433244 +Sensor at x=3215227, y=3077078: closest beacon is at x=3677247, y=3140958 +Sensor at x=2209379, y=3030851: closest beacon is at x=2121069, y=3230302 \ No newline at end of file diff --git a/src/common/pos.rs b/src/common/pos.rs index d5ffb07..5e692a2 100644 --- a/src/common/pos.rs +++ b/src/common/pos.rs @@ -22,6 +22,10 @@ impl Pos where T: Num + Copy, { + pub fn splat(v: T) -> Pos { + Pos(v, v) + } + pub fn x(&self) -> T { self.0 } @@ -259,3 +263,16 @@ where Pos::mul(*self, *rhs) } } + +impl Pos +where + T: Num + Signed + Copy, +{ + pub fn taxicab_origin(&self) -> T { + self.0.abs() + self.1.abs() + } + + pub fn taxicab(&self, other: &Pos) -> T { + (self.0 - other.0).abs() + (self.1 - other.1).abs() + } +} diff --git a/src/days/day02/mod.rs b/src/days/day02/mod.rs index 39c5efb..73fc25e 100644 --- a/src/days/day02/mod.rs +++ b/src/days/day02/mod.rs @@ -215,7 +215,7 @@ mod test { fn test_part2() -> Result<()> { let day = Day {}; let lines = read_lines(day.get_day_number(), "example01.txt")?; - let expected = ResultType::Nothing; + let expected = ResultType::Integer(12); let result = day.part2(&lines)?; assert_eq!(result, expected); diff --git a/src/days/day07/mod.rs b/src/days/day07/mod.rs new file mode 100644 index 0000000..8c4c791 --- /dev/null +++ b/src/days/day07/mod.rs @@ -0,0 +1,341 @@ +use std::{ + cell::{Cell, RefCell}, + num::ParseIntError, + rc::{Rc, Weak}, +}; + +use super::template::{DayTrait, ResultType}; +use thiserror::Error; + +const DAY_NUMBER: usize = 7; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let root = Directory::parse(lines)?; + let result = root + .iter() + .filter_map(|dir| { + let size = dir.size(); + if size <= 100000 { + Some(size) + } else { + None + } + }) + .sum(); + Ok(ResultType::Integer(result)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + const AVAIL: i64 = 70_000_000; + const REQUIRED: i64 = 30_000_000; + let root = Directory::parse(lines)?; + let to_free = REQUIRED - (AVAIL - root.size()); + let result = root + .iter() + .filter_map(|dir| { + let size = dir.size(); + if size >= to_free { + Some(size) + } else { + None + } + }) + .min() + .unwrap_or(0); + Ok(ResultType::Integer(result)) + } +} + +#[derive(Debug, Error)] +enum DirectoryError { + #[error("Directory does not exist: {0}")] + NoSuchDirectory(String), + + #[error("Directory has no parent")] + NoParentDirectory, + + #[error("Illegal command: {0}")] + IllegalCommand(String), + + #[error("No a legal Number")] + IllegalNumber(#[from] ParseIntError), +} + +#[derive(Debug)] +struct Node { + parent: Option>>, + name: String, + sub_dirs: Vec>>, + file_size: i64, + size: Cell>, +} + +impl Node { + fn root() -> Node { + Node { + parent: None, + name: "/".to_owned(), + sub_dirs: vec![], + file_size: 0, + size: Cell::new(None), + } + } + + fn add_subdir(&mut self, subdir: Rc>) { + self.sub_dirs.push(subdir); + } + + fn add_file(&mut self, _name: &str, size: i64) { + self.file_size += size; + } + + fn size(&self) -> i64 { + self.size.get().unwrap_or_else(|| { + let subsize: i64 = self.sub_dirs.iter().map(|sub| sub.borrow().size()).sum(); + let size = subsize + self.file_size; + + self.size.set(Some(size)); + size + }) + } +} + +#[derive(Debug, Clone)] +struct Directory { + node: Rc>, +} + +impl Directory { + pub fn root() -> Directory { + Directory { + node: Rc::new(RefCell::new(Node::root())), + } + } + + fn create(node: Rc>) -> Directory { + Directory { node } + } + + #[allow(dead_code)] + pub fn name(&self) -> String { + self.node.borrow().name.to_string() + } + + pub fn size(&self) -> i64 { + self.node.borrow().size() + } + + #[allow(dead_code)] + pub fn file_size(&self) -> i64 { + self.node.borrow().file_size + } + + pub fn add_subdir(&mut self, name: &str) { + let subdir = Rc::new(RefCell::new(Node { + parent: Some(Rc::downgrade(&self.node)), + name: name.to_owned(), + sub_dirs: vec![], + file_size: 0, + size: Cell::new(None), + })); + self.node.borrow_mut().add_subdir(subdir); + } + + pub fn add_file(&mut self, name: &str, size: i64) { + self.node.borrow_mut().add_file(name, size) + } + + pub fn parent(&self) -> Option { + self.node + .borrow() + .parent + .as_ref() + .and_then(|node| node.upgrade()) + .map(|node| Directory { node }) + } + + pub fn get_subdir(&self, name: &str) -> Option { + let node = self.node.borrow(); + let sub_node = node.sub_dirs.iter().find(|node| node.borrow().name == name); + sub_node.map(|node| Directory::create(node.clone())) + } + + pub fn parse(lines: &[String]) -> Result { + let root = Directory::root(); + let mut current = root.clone(); + for line in lines { + match line.split_whitespace().collect::>()[..] { + ["$", "cd", dir] => { + current = match dir { + "/" => root.clone(), + ".." => { + let Some(next) = current.parent() else { + return Err(DirectoryError::NoParentDirectory); + }; + next + } + _ => { + let Some(next) = current.get_subdir(dir) else { + return Err(DirectoryError::NoSuchDirectory(dir.to_owned())) + }; + next + } + }; + } + ["$", "ls"] => {} // Command can safely be ignored + ["dir", name] => { + current.add_subdir(name); + } + [size, name] => { + let size = size.parse::()?; + current.add_file(name, size); + } + _ => return Err(DirectoryError::IllegalCommand(line.to_owned())), + } + } + Ok(root) + } + + pub fn iter(&self) -> DirectoryIterator { + DirectoryIterator::create(self.node.clone()) + } +} + +#[derive(Debug)] +struct DirectoryIterator { + directory: Rc>, + subdirectory: Option<(usize, Box)>, + finished: bool, +} + +impl DirectoryIterator { + pub fn create(directory: Rc>) -> DirectoryIterator { + DirectoryIterator { + directory, + subdirectory: None, + finished: false, + } + } +} + +impl Iterator for DirectoryIterator { + type Item = Directory; + + fn next(&mut self) -> Option { + if self.finished { + return None; + } + if let Some((subdirectory, sub_iterator)) = self.subdirectory.as_mut() { + if let Some(next) = sub_iterator.next() { + Some(next) + } else { + let dir = self.directory.borrow(); + let subdirectory = *subdirectory + 1; + if subdirectory < dir.sub_dirs.len() { + let subdir = dir.sub_dirs[subdirectory].clone(); + let mut sub_iterator = DirectoryIterator::create(subdir); + let result = sub_iterator.next(); + self.subdirectory = Some((subdirectory, Box::new(sub_iterator))); + result + } else { + self.finished = true; + None + } + } + } else { + let dir = self.directory.borrow(); + if !dir.sub_dirs.is_empty() { + let subdir = dir.sub_dirs[0].clone(); + let sub_iterator = DirectoryIterator::create(subdir); + self.subdirectory = Some((0, Box::new(sub_iterator))); + } else { + self.finished = true; + } + + Some(Directory { + node: self.directory.clone(), + }) + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + + #[test] + fn test_create_directory() { + let directory = Directory::root(); + assert_eq!(directory.name(), "/"); + assert_eq!(directory.size(), 0); + } + + #[test] + fn test_create_and_get_subdir() { + let mut root = Directory::root(); + root.add_file("file1", 100); + root.add_file("file2", 200); + root.add_subdir("subdir"); + let mut subdir = root.get_subdir("subdir").unwrap(); + subdir.add_file("file3", 300); + subdir.add_file("file4", 400); + + assert_eq!(subdir.name(), "subdir"); + assert_eq!(subdir.size(), 700); + assert_eq!(root.size(), 1000); + assert_eq!(root.file_size(), 300); + } + + #[test] + fn test_total_size() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let dir = Directory::parse(&lines)?; + assert_eq!(dir.size(), 48381165); + + Ok(()) + } + + #[test] + fn test_iterator() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = vec!["/", "a", "e", "d"]; + let dir = Directory::parse(&lines)?; + let result: Vec<_> = dir.iter().map(|dir| dir.name()).collect(); + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(95437); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(24933642); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day08/mod.rs b/src/days/day08/mod.rs new file mode 100644 index 0000000..77b5fcc --- /dev/null +++ b/src/days/day08/mod.rs @@ -0,0 +1,232 @@ +use super::template::{DayTrait, ResultType}; +use itertools::{iproduct, FoldWhile, Itertools}; +use thiserror::Error; + +const DAY_NUMBER: usize = 8; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let forest = Forest::parse(lines)?; + let result = forest.count_visible(); + Ok(ResultType::Integer(result)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let forest = Forest::parse(lines)?; + let result = forest.best_score(); + Ok(ResultType::Integer(result)) + } +} + +#[derive(Debug, Error)] +enum ForestError { + #[error("Not a legal digit: {0}")] + NoLegalDigit(char), + + #[error("The Forst is not a rectangle")] + NonRectangleForest, + + #[error("Zero Sized Forest not allowed")] + NoZeroSizedForest, +} + +#[derive(Debug)] +struct Forest { + trees: Vec>, + width: usize, + height: usize, +} + +impl Forest { + pub fn create(trees: Vec>) -> Result { + let height = trees.len(); + if height == 0 { + return Err(ForestError::NoZeroSizedForest); + } + let width = trees[0].len(); + if width == 0 { + return Err(ForestError::NoZeroSizedForest); + } + + for row in trees.iter() { + if row.len() != width { + return Err(ForestError::NonRectangleForest); + } + } + + Ok(Forest { + trees, + width, + height, + }) + } + + pub fn parse(lines: &[String]) -> Result { + lines + .iter() + .map(|line| { + line.chars() + .map(|height| height.to_digit(10).ok_or(ForestError::NoLegalDigit(height))) + .collect::, _>>() + }) + .collect::, _>>() + .and_then(Forest::create) + } + + pub fn count_visible(&self) -> i64 { + let mut vis_count = 2 * (self.width + self.height - 2) as i64; + let mut visible = vec![vec![false; self.width - 2]; self.height - 2]; + + for y in 1..self.height - 1 { + let mut talest_seen = self.trees[y][0]; + for x in 1..self.width - 1 { + let tree = self.trees[y][x]; + if tree > talest_seen { + vis_count += 1; + visible[y - 1][x - 1] = true; + talest_seen = self.trees[y][x]; + } + } + + let mut talest_seen = self.trees[y][self.width - 1]; + for x in (1..self.width - 1).rev() { + let tree = self.trees[y][x]; + if tree > talest_seen { + if !visible[y - 1][x - 1] { + vis_count += 1; + visible[y - 1][x - 1] = true; + } + talest_seen = self.trees[y][x]; + } + } + } + + for x in 1..self.width - 1 { + let mut talest_seen = self.trees[0][x]; + for y in 1..self.height - 1 { + let tree = self.trees[y][x]; + if tree > talest_seen { + if !visible[y - 1][x - 1] { + vis_count += 1; + visible[y - 1][x - 1] = true; + } + talest_seen = self.trees[y][x]; + } + } + + let mut talest_seen = self.trees[self.height - 1][x]; + for y in (1..self.height - 1).rev() { + let tree = self.trees[y][x]; + if tree > talest_seen { + if !visible[y - 1][x - 1] { + vis_count += 1; + visible[y - 1][x - 1] = true; + } + talest_seen = self.trees[y][x]; + } + } + } + + vis_count + } + + pub fn best_score(&self) -> i64 { + iproduct!(1..self.width - 1, 1..self.height - 1) + .map(|(x, y)| self.score(x, y)) + .max() + // None can only happen when we have a forrest with no inner trees. + // In that case 0 is the correct solution. + // We already forbid zero height and zero width forests during create. + .unwrap_or(0) + } + + fn score(&self, x: usize, y: usize) -> i64 { + let tree = self.trees[y][x]; + let left = (0..x) + .rev() + .fold_while(0, |acc, x| { + if self.trees[y][x] < tree { + FoldWhile::Continue(acc + 1) + } else { + FoldWhile::Done(acc + 1) + } + }) + .into_inner(); + let right = (x + 1..self.width) + .fold_while(0, |acc, x| { + if self.trees[y][x] < tree { + FoldWhile::Continue(acc + 1) + } else { + FoldWhile::Done(acc + 1) + } + }) + .into_inner(); + let up = (0..y) + .rev() + .fold_while(0, |acc, y| { + if self.trees[y][x] < tree { + FoldWhile::Continue(acc + 1) + } else { + FoldWhile::Done(acc + 1) + } + }) + .into_inner(); + let down = (y + 1..self.height) + .fold_while(0, |acc, y| { + if self.trees[y][x] < tree { + FoldWhile::Continue(acc + 1) + } else { + FoldWhile::Done(acc + 1) + } + }) + .into_inner(); + + left * right * up * down + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + + #[test] + fn test_parse() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let forest = Forest::parse(&lines)?; + assert_eq!(forest.width, 5); + assert_eq!(forest.height, 5); + + Ok(()) + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(21); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(8); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day09/mod.rs b/src/days/day09/mod.rs new file mode 100644 index 0000000..533acf4 --- /dev/null +++ b/src/days/day09/mod.rs @@ -0,0 +1,152 @@ +use super::template::{DayTrait, ResultType}; +use crate::common::{direction::Direction, pos::Pos}; +use std::{collections::HashSet, num::ParseIntError}; +use thiserror::Error; + +const DAY_NUMBER: usize = 9; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let commands = parse_commands(lines)?; + let mut rope = Rope::create(2); + let result = rope.run(&commands); + Ok(ResultType::Integer(result)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let commands = parse_commands(lines)?; + let mut rope = Rope::create(10); + let result = rope.run(&commands); + Ok(ResultType::Integer(result)) + } +} + +#[derive(Debug, Error)] +enum RopeError { + #[error("Not a legal command {0}")] + CommandUnknown(String), + + #[error["not a legal Direction {0}"]] + DirectionUnknown(String), + + #[error("Not a legal Integer")] + StepParseError(#[from] ParseIntError), +} + +fn parse_commands(lines: &[String]) -> Result, RopeError> { + lines.iter().map(parse_line).collect::>() +} + +fn parse_line(line: &String) -> Result<(Direction, usize), RopeError> { + match line.split_whitespace().collect::>()[..] { + [direction, steps] => { + let direction = match direction { + "U" => Direction::North, + "D" => Direction::South, + "R" => Direction::East, + "L" => Direction::West, + _ => { + return Err(RopeError::DirectionUnknown(direction.to_owned())); + } + }; + let steps = steps.parse()?; + Ok((direction, steps)) + } + _ => Err(RopeError::CommandUnknown(line.to_owned())), + } +} + +fn get_closer(first: Pos, second: Pos) -> Option> { + let diff = second - first; + if diff.x().abs() <= 1 && diff.y().abs() <= 1 { + None + } else { + Some(Pos::new(diff.x().signum(), diff.y().signum())) + } +} + +#[derive(Debug)] +struct Rope { + head: Pos, + knots: Vec>, +} + +impl Rope { + pub fn create(length: usize) -> Self { + assert!(length >= 2); + Rope { + head: Pos::new(0, 0), + knots: vec![Pos::new(0, 0); length - 1], + } + } + + /** + * Moves the head one step into the given direction + * returns true if the whole rope moved, otherwise false + */ + pub fn move_rope(&mut self, head_direction: Direction) -> bool { + self.head = self.head + head_direction; + let mut prev = self.head; + let mut knots_unmoved = self.knots.len(); + + for knot in self.knots.iter_mut() { + if let Some(diff) = get_closer(*knot, prev) { + *knot = *knot + diff; + prev = *knot; + knots_unmoved -= 1; + } else { + break; + } + } + knots_unmoved == 0 + } + + pub fn run(&mut self, commands: &[(Direction, usize)]) -> i64 { + let mut tail_visited = HashSet::new(); + tail_visited.insert(self.knots.last().copied().unwrap()); + + for (direction, steps) in commands { + for _ in 0..*steps { + if self.move_rope(*direction) { + tail_visited.insert(self.knots.last().copied().unwrap()); + } + } + } + tail_visited.len() as i64 + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(13); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example02.txt")?; + let expected = ResultType::Integer(36); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day10/mod.rs b/src/days/day10/mod.rs new file mode 100644 index 0000000..13bfdcf --- /dev/null +++ b/src/days/day10/mod.rs @@ -0,0 +1,165 @@ +use super::template::{DayTrait, ResultType}; +use std::{num::ParseIntError, slice::Iter}; +use thiserror::Error; + +const DAY_NUMBER: usize = 10; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let instructions = lines + .iter() + .map(|line| Instruction::parse(line)) + .collect::, _>>()?; + let result = CpuCycles::signal_strength(&instructions, &[20, 60, 100, 140, 180, 220]); + Ok(ResultType::Integer(result as i64)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let instructions = lines + .iter() + .map(|line| Instruction::parse(line)) + .collect::, _>>()?; + let result = CpuCycles::draw(&instructions); + Ok(ResultType::Lines(result)) + } +} + +#[derive(Debug, Error)] +enum CpuError { + #[error("unknown instruction: {0}")] + UnknownInstruction(String), + + #[error("could not parse Number")] + InvalidInteger(#[from] ParseIntError), +} + +enum Instruction { + Add(i32), + Noop, +} + +impl Instruction { + pub fn parse(line: &str) -> Result { + if line == "noop" { + Ok(Instruction::Noop) + } else if line.starts_with("addx") { + let value = line[5..].parse()?; + Ok(Instruction::Add(value)) + } else { + Err(CpuError::UnknownInstruction(line.to_owned())) + } + } +} + +struct CpuCycles<'a> { + register: i32, + instructions: Iter<'a, Instruction>, + current: Option, +} + +impl<'a> CpuCycles<'a> { + pub fn create(instructions: &'a [Instruction]) -> Self { + Self { + instructions: instructions.iter(), + register: 1, + current: None, + } + } + + pub fn signal_strength(instructions: &'a [Instruction], to_collect: &[usize]) -> i32 { + CpuCycles::create(instructions) + .enumerate() + .filter_map(|(cycle, register)| { + if to_collect.contains(&(cycle + 1)) { + Some(register * (cycle + 1) as i32) + } else { + None + } + }) + .sum() + } + + pub fn draw(instructions: &'a [Instruction]) -> Vec { + let mut result = Vec::new(); + let mut line = "".to_owned(); + for (cycle, sprite) in CpuCycles::create(instructions).enumerate() { + let cycle = (cycle % 40) as i32; + if (sprite - cycle).abs() <= 1 { + line.push('#'); + } else { + line.push(' '); + } + if cycle == 39 { + result.push(line.to_owned()); + line = "".to_owned(); + } + } + result + } +} + +impl<'a> Iterator for CpuCycles<'a> { + type Item = i32; + + fn next(&mut self) -> Option { + if let Some(value) = self.current { + let start_register = self.register; + self.register += value; + self.current = None; + Some(start_register) + } else if let Some(instruction) = self.instructions.next() { + match instruction { + Instruction::Add(value) => self.current = Some(*value), + Instruction::Noop => {} + } + Some(self.register) + } else { + None + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + + #[test] + fn test_simple() -> Result<()> { + let instructions = vec![Instruction::Noop, Instruction::Add(3), Instruction::Add(-5)]; + let expected = vec![1, 1, 1, 4, 4]; + let result = CpuCycles::create(&instructions).collect::>(); + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(13140); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Lines(read_lines(day.get_day_number(), "expected01.txt")?); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day11/mod.rs b/src/days/day11/mod.rs new file mode 100644 index 0000000..0f2cd1e --- /dev/null +++ b/src/days/day11/mod.rs @@ -0,0 +1,246 @@ +use super::template::{DayTrait, ResultType}; +use lazy_static::lazy_static; +use regex::Regex; +use std::{iter::zip, num::ParseIntError}; +use thiserror::Error; + +const DAY_NUMBER: usize = 11; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let troop = Troop::parse(lines)?; + Ok(ResultType::Integer(troop.play(20))) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let troop = Troop::parse(lines)?; + Ok(ResultType::Integer(troop.play_again(10_000))) + } +} + +#[derive(Debug, Error)] +enum MonkeyError { + #[error("Not an Integer")] + NotAnInteger(#[from] ParseIntError), + + #[error("Can't parse line: {0}")] + UnknownLine(String), + + #[error("Did not expect end of Input")] + PrematureEndOfInput, +} + +#[derive(Debug, PartialEq)] +enum Operation { + Plus(i64), + Times(i64), + Squared, +} + +impl Operation { + pub fn parse(line: &str) -> Operation { + match line.split_whitespace().collect::>()[..] { + ["*", "old"] => Operation::Squared, + ["*", value] => Operation::Times(value.parse().unwrap()), + ["+", value] => Operation::Plus(value.parse().unwrap()), + _ => unreachable!(), + } + } + + pub fn calc(&self, old: i64) -> i64 { + match self { + Operation::Plus(value) => old + *value, + Operation::Times(value) => old * value, + Operation::Squared => old.pow(2), + } + } +} + +#[derive(Debug, PartialEq)] +struct Monkey { + number: usize, + items: Vec, + operation: Operation, + divisor: i64, + good_monkey: usize, + bad_monkey: usize, +} + +lazy_static! { + static ref MONKEY: Regex = Regex::new(r"Monkey (\d+)").unwrap(); + static ref STARTING: Regex = Regex::new(r"Starting items: (\d+(?:, \d+)*)").unwrap(); + static ref OP: Regex = Regex::new(r"Operation: new = old ([+*] \d+|\* old)").unwrap(); + static ref TEST: Regex = Regex::new(r"Test: divisible by (\d+)").unwrap(); + static ref NEXT: Regex = Regex::new(r"If (?:true|false): throw to monkey (\d+)").unwrap(); +} + +impl Monkey { + fn parse_line<'a>(re: &Regex, line: &'a str) -> Result<&'a str, MonkeyError> { + let caps = re + .captures(line) + .ok_or(MonkeyError::UnknownLine(line.to_owned()))?; + Ok(caps.get(1).unwrap().as_str()) + } + + pub fn parse_one( + iterator: &mut dyn Iterator, + ) -> Result, MonkeyError> { + if let Some(line) = iterator.next() { + let number: usize = Monkey::parse_line(&MONKEY, line)?.parse()?; + + let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?; + let start = Monkey::parse_line(&STARTING, line)?; + let items = start + .split(", ") + .map(|item| item.parse::()) + .collect::, _>>()?; + + let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?; + let operation = Operation::parse(Monkey::parse_line(&OP, line)?); + + let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?; + let divisor: i64 = Monkey::parse_line(&TEST, line)?.parse()?; + + let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?; + let good_monkey: usize = Monkey::parse_line(&NEXT, line)?.parse()?; + + let line = iterator.next().ok_or(MonkeyError::PrematureEndOfInput)?; + let bad_monkey: usize = Monkey::parse_line(&NEXT, line)?.parse()?; + + iterator.next(); + + Ok(Some(Monkey { + number, + items, + operation, + divisor, + good_monkey, + bad_monkey, + })) + } else { + Ok(None) + } + } + + pub fn process(&self, value: i64) -> i64 { + self.operation.calc(value) + } + + pub fn check(&self, value: i64) -> bool { + value % self.divisor == 0 + } +} + +struct Troop { + monkeys: Vec, +} + +impl Troop { + pub fn parse(lines: &[String]) -> Result { + let mut iter = lines.iter(); + let mut monkeys = Vec::new(); + while let Some(monkey) = Monkey::parse_one(&mut iter)? { + monkeys.push(monkey); + } + Ok(Troop { monkeys }) + } + + fn do_play(&self, rounds: usize, alter: F) -> i64 + where + F: Fn(i64) -> i64, + { + let mut holding = vec![Vec::new(); self.monkeys.len()]; + let mut inspected = vec![0i64; self.monkeys.len()]; + for (holding, monkey) in zip(&mut holding, &self.monkeys) { + holding.extend(&monkey.items); + } + for _ in 0..rounds { + for (pos, monkey) in self.monkeys.iter().enumerate() { + let (good, bad): (Vec<_>, Vec<_>) = holding[pos] + .iter() + .map(|value| alter(monkey.process(*value))) + .partition(|value| monkey.check(*value)); + inspected[pos] += holding[pos].len() as i64; + holding.get_mut(pos).unwrap().clear(); + holding.get_mut(monkey.good_monkey).unwrap().extend(&good); + holding.get_mut(monkey.bad_monkey).unwrap().extend(&bad); + } + } + + inspected.sort_by(|a, b| b.cmp(a)); + inspected.iter().take(2).product() + } + + pub fn play(&self, rounds: usize) -> i64 { + self.do_play(rounds, |v| v / 3) + } + + pub fn play_again(&self, rounds: usize) -> i64 { + let divisor: i64 = self.monkeys.iter().map(|monkey| monkey.divisor).product(); + self.do_play(rounds, |v| v % divisor) + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + + #[test] + fn test_parse() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = Monkey { + number: 0, + items: vec![79, 98], + operation: Operation::Times(19), + divisor: 23, + good_monkey: 2, + bad_monkey: 3, + }; + let result = Monkey::parse_one(&mut lines.iter())?.unwrap(); + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_parse_all() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = 4; + let result = Troop::parse(&lines)?; + assert_eq!(result.monkeys.len(), expected); + + Ok(()) + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(10605); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(2713310158); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day12/mod.rs b/src/days/day12/mod.rs new file mode 100644 index 0000000..c3f6ab1 --- /dev/null +++ b/src/days/day12/mod.rs @@ -0,0 +1,294 @@ +use std::collections::{BinaryHeap, HashSet}; + +use crate::common::pos::Pos; + +use super::template::{DayTrait, ResultType}; +use thiserror::Error; + +const DAY_NUMBER: usize = 12; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let valley = Valley::parse(lines)?; + Ok(ResultType::Integer(valley.walk()? as i64)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let valley = Valley::parse(lines)?; + Ok(ResultType::Integer(valley.walk_short()? as i64)) + } +} + +#[derive(Debug, Error)] +enum ValleyError { + #[error("Not a legal terrain char: {0}")] + NotALegalCharacter(char), + #[error("Valley needs to be rectangle")] + NotAReactangleValley, + #[error("Valley map conatins no data")] + EmptyValley, + #[error("Could not find start point")] + NoStartFound, + #[error("Could not find exit point")] + NoExitFound, + #[error("No path found")] + NoPathFound, +} + +#[derive(Debug, PartialEq, Eq)] +struct Path { + length: usize, + height: char, + pos: Pos, +} + +impl PartialOrd for Path { + fn partial_cmp(&self, other: &Self) -> Option { + match other.length.partial_cmp(&self.length) { + Some(core::cmp::Ordering::Equal) => {} + ord => return ord, + } + match other.height.partial_cmp(&self.height) { + Some(core::cmp::Ordering::Equal) => {} + ord => return ord, + } + match self.pos.x().partial_cmp(&other.pos.x()) { + Some(core::cmp::Ordering::Equal) => {} + ord => return ord, + } + self.pos.y().partial_cmp(&other.pos.y()) + } +} + +impl Ord for Path { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + other + .length + .cmp(&self.length) + .then_with(|| other.height.cmp(&self.height)) + .then_with(|| self.pos.x().cmp(&other.pos.x())) + .then_with(|| self.pos.y().cmp(&other.pos.y())) + } +} + +impl Path { + pub fn new(length: usize, height: char, pos: Pos) -> Self { + Path { + length, + height, + pos, + } + } + + pub fn next_path<'a>(&'a self, valley: &'a Valley) -> Neighbors<'a> { + Neighbors::new(self, valley) + } +} + +struct Neighbors<'a> { + path: &'a Path, + valley: &'a Valley, + state: usize, +} + +impl<'a> Neighbors<'a> { + pub fn new(path: &'a Path, valley: &'a Valley) -> Self { + Neighbors { + path, + state: 0, + valley, + } + } + + fn next_pos(&mut self) -> Option> { + while self.state < 4 { + self.state += 1; + match self.state { + 1 => { + if self.path.pos.x() < self.valley.width() - 1 { + return Some(Pos::new(self.path.pos.x() + 1, self.path.pos.y())); + } + } + 2 => { + if self.path.pos.y() > 0 { + return Some(Pos::new(self.path.pos.x(), self.path.pos.y() - 1)); + } + } + 3 => { + if self.path.pos.x() > 0 { + return Some(Pos::new(self.path.pos.x() - 1, self.path.pos.y())); + } + } + 4 => { + if self.path.pos.y() < self.valley.height() - 1 { + return Some(Pos::new(self.path.pos.x(), self.path.pos.y() + 1)); + } + } + _ => {} + } + } + None + } +} + +impl Iterator for Neighbors<'_> { + type Item = Path; + + fn next(&mut self) -> Option { + while let Some(pos) = self.next_pos() { + let height = self.valley.get_height(pos); + if height as u32 + 1 >= self.path.height as u32 { + return Some(Path::new(self.path.length + 1, height, pos)); + } + } + None + } +} + +struct Valley { + map: Vec>, + start: Pos, + exit: Pos, + width: usize, +} + +impl Valley { + pub fn parse(lines: &[String]) -> Result { + let mut map = Vec::new(); + let mut start = None; + let mut exit = None; + let mut valley_width = None; + for (y, row) in lines.iter().enumerate() { + let mut height_row = Vec::new(); + for (x, height_char) in row.chars().enumerate() { + match height_char { + 'S' => { + start = Some(Pos::new(x, y)); + height_row.push('a') + } + 'E' => { + exit = Some(Pos::new(x, y)); + height_row.push('z') + } + 'a'..='z' => height_row.push(height_char), + _ => return Err(ValleyError::NotALegalCharacter(height_char)), + } + } + if let Some(width) = valley_width { + if width != height_row.len() { + return Err(ValleyError::NotAReactangleValley); + } + } else { + valley_width = Some(height_row.len()); + } + map.push(height_row); + } + let Some(width) = valley_width else { + return Err(ValleyError::EmptyValley); + }; + let Some(start) = start else { + return Err(ValleyError::NoStartFound); + }; + let Some(exit) = exit else { + return Err(ValleyError::NoExitFound); + }; + Ok(Valley { + map, + start, + exit, + width, + }) + } + + fn get_height(&self, pos: Pos) -> char { + self.map[pos.y()][pos.x()] + } + + fn do_walk(&self, check: F) -> Result + where + F: Fn(Pos) -> bool, + { + let mut shortest = HashSet::with_capacity(self.width * self.map.len()); + let mut queue = BinaryHeap::new(); + queue.push(Path::new(0, 'z', self.exit)); + while let Some(current) = queue.pop() { + if check(current.pos) { + return Ok(current.length); + } + if shortest.contains(¤t.pos) { + continue; + } + shortest.insert(current.pos); + for next in current.next_path(self) { + queue.push(next); + } + } + + Err(ValleyError::NoPathFound) + } + + pub fn walk(&self) -> Result { + self.do_walk(|pos| pos == self.start) + } + + pub fn walk_short(&self) -> Result { + self.do_walk(|pos| self.get_height(pos) == 'a') + } + + #[inline] + fn width(&self) -> usize { + self.width + } + + #[inline] + fn height(&self) -> usize { + self.map.len() + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + + #[test] + fn test_parse() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let valley = Valley::parse(&lines)?; + assert_eq!(valley.width, 8); + assert_eq!(valley.start, Pos::new(0, 0)); + assert_eq!(valley.exit, Pos::new(5, 2)); + + Ok(()) + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(31); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(29); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day13/mod.rs b/src/days/day13/mod.rs new file mode 100644 index 0000000..0e33a74 --- /dev/null +++ b/src/days/day13/mod.rs @@ -0,0 +1,220 @@ +use std::cmp::Ordering; + +use super::template::{DayTrait, ResultType}; +use itertools::Itertools; +use thiserror::Error; + +const DAY_NUMBER: usize = 13; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let packets = Packets::parse_all(lines)?; + let result: i64 = packets + .iter() + .tuples() + .enumerate() + .filter_map(|(pos, (first, second))| { + if first < second { + Some(pos as i64 + 1) + } else { + None + } + }) + .sum(); + Ok(ResultType::Integer(result)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let small = Packets::parse("[[2]]")?; + let large = Packets::parse("[[6]]")?; + let mut pos_small = 1; + let mut pos_large = 2; + let packets = Packets::parse_all(lines)?; + for packet in packets { + if packet < small { + pos_small += 1; + pos_large += 1; + } else if packet < large { + pos_large += 1; + } + } + Ok(ResultType::Integer(pos_small * pos_large)) + } +} + +#[derive(Debug, Error)] +enum PacketError { + #[error("Empty Packet not allowed")] + EmptyPacketNotAllowed, + #[error("Packtet must start with a [ was: {0}")] + ExpectedSquare(char), + #[error("Unknown char: {0}")] + UnknownChar(char), + #[error("End of input reached to early")] + PrematureEndOfInput, + #[error("Number was not terminated correctly")] + UnfinishedNumber, +} + +#[derive(Debug, PartialEq, Eq, Clone)] +enum Packets { + Number(u32), + List(Vec), +} + +impl PartialOrd for Packets { + fn partial_cmp(&self, other: &Self) -> Option { + match (self, other) { + (Packets::Number(first), Packets::Number(second)) => first.partial_cmp(second), + (Packets::List(first), Packets::List(second)) => { + for pair in first.iter().zip_longest(second.iter()) { + let result = match pair { + itertools::EitherOrBoth::Left(_) => Some(Ordering::Greater), + itertools::EitherOrBoth::Right(_) => Some(Ordering::Less), + itertools::EitherOrBoth::Both(first, second) => first.partial_cmp(second), + }; + if !matches!(result, Some(Ordering::Equal)) { + return result; + } + } + Some(Ordering::Equal) + } + (Packets::Number(_), Packets::List(_)) => self.as_list().partial_cmp(other), + (Packets::List(_), Packets::Number(_)) => self.partial_cmp(&other.as_list()), + } + } +} + +impl Packets { + pub fn as_list(&self) -> Packets { + match self { + Packets::Number(_) => Packets::List(vec![self.clone()]), + Packets::List(_) => self.clone(), + } + } + + pub fn parse(line: &str) -> Result { + let mut chars = line.chars(); + let Some(start) = chars.next() else { + return Err(PacketError::EmptyPacketNotAllowed); + }; + if start != '[' { + return Err(PacketError::ExpectedSquare(start)); + } + let packet = Packets::parse_one(&mut chars)?; + Ok(packet) + } + + fn parse_one(chars: &mut dyn Iterator) -> Result { + let mut list = Vec::new(); + let mut number = None; + while let Some(next) = chars.next() { + match next { + '[' => { + if number.is_some() { + return Err(PacketError::UnfinishedNumber); + } + list.push(Packets::parse_one(chars)?); + } + ']' => { + if let Some(number) = number { + list.push(Packets::Number(number)); + } + return Ok(Packets::List(list)); + } + ',' => { + if let Some(number) = number { + list.push(Packets::Number(number)); + } + number = None; + } + '0'..='9' => match number { + None => number = Some(next.to_digit(10).unwrap()), + Some(prev) => number = Some(prev * 10 + next.to_digit(10).unwrap()), + }, + _ => return Err(PacketError::UnknownChar(next)), + } + } + Err(PacketError::PrematureEndOfInput) + } + + pub fn parse_all(lines: &[String]) -> Result, PacketError> { + lines + .iter() + .filter(|line| !line.is_empty()) + .map(|line| Packets::parse(line)) + .collect::, _>>() + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + + #[test] + fn test_parse() -> Result<()> { + let input = "[[1],[2,3]]"; + let expected = Packets::List(vec![ + Packets::List(vec![Packets::Number(1)]), + Packets::List(vec![Packets::Number(2), Packets::Number(3)]), + ]); + let result = Packets::parse(input)?; + assert_eq!(result, expected); + Ok(()) + } + + #[test] + fn test_parse_all() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let result = Packets::parse_all(&lines)?; + assert_eq!(result.len(), 16); + Ok(()) + } + + #[test] + fn test_compare_all() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = vec![true, true, false, true, false, true, false, false]; + let result = Packets::parse_all(&lines)?; + let compare = result + .iter() + .tuples() + .map(|(first, second)| first < second) + .collect::>(); + assert_eq!(compare, expected); + + Ok(()) + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(13); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(140); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day14/mod.rs b/src/days/day14/mod.rs new file mode 100644 index 0000000..e8ace33 --- /dev/null +++ b/src/days/day14/mod.rs @@ -0,0 +1,292 @@ +use itertools::Itertools; +use std::{collections::HashSet, num::ParseIntError}; +use thiserror::Error; + +use crate::common::pos::Pos; + +use super::template::{DayTrait, ResultType}; + +const DAY_NUMBER: usize = 14; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let cave = Cave::parse(lines)?; + Ok(ResultType::Integer(cave.drop_bottomless() as i64)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let cave = Cave::parse(lines)?; + Ok(ResultType::Integer(cave.drop_floor())) + } +} + +#[derive(Debug, Error)] +enum CaveError { + #[error("Could not parse")] + ParseError, + + #[error("Error, while paring int")] + NotAValidInteger(#[from] ParseIntError), + + #[error("Not a valid Pos {0}")] + NotAValidPos(String), + + #[error("Found an empty path")] + EmptyPath, + + #[error("Found an empty cave")] + EmptyCave, +} + +struct Cave { + map: Vec>, + min_x: i32, + max_x: i32, + height: i32, +} + +impl Cave { + fn get(&self, map: &[Vec], pos: Pos) -> bool { + if pos.y() >= self.height || pos.x() < self.min_x || pos.x() > self.max_x { + false + } else { + map[pos.y() as usize][(pos.x() - self.min_x) as usize] + } + } + + fn set(&self, map: &mut [Vec], pos: Pos) { + map[pos.y() as usize][(pos.x() - self.min_x) as usize] = true + } + + fn walk(from: Pos, to: Pos) -> Result>, CaveError> { + if from == to { + return Ok(vec![from]); + } + if from.x() == to.x() { + if from.y() < to.y() { + Ok((from.y()..to.y()).map(|y| Pos::new(from.x(), y)).collect()) + } else { + Ok(((to.y() + 1)..=from.y()) + .map(|y| Pos::new(from.x(), y)) + .collect()) + } + } else if from.y() == to.y() { + if from.x() < to.x() { + Ok((from.x()..to.x()).map(|x| Pos::new(x, from.y())).collect()) + } else { + Ok(((to.x() + 1)..=from.x()) + .map(|x| Pos::new(x, from.y())) + .collect()) + } + } else { + Err(CaveError::ParseError) + } + } + + fn parse_one(line: &str) -> Result>, CaveError> { + let corners = line + .split("->") + .map(|coord| match coord.split(',').collect::>()[..] { + [first, second] => { + let x: i32 = first.trim().parse()?; + let y = second.trim().parse()?; + Ok(Pos::new(x, y)) + } + _ => Err(CaveError::NotAValidPos(coord.to_owned())), + }) + .collect::, CaveError>>()?; + + if corners.is_empty() { + return Err(CaveError::EmptyPath); + } + + let blocks = corners + .iter() + .tuple_windows() + .map(|(first, second)| Cave::walk(*first, *second)) + .collect::, _>>()?; + + let mut blocks = blocks.iter().flatten().copied().collect::>(); + blocks.insert(*corners.last().unwrap()); + + Ok(blocks) + } + + pub fn parse(lines: &[String]) -> Result { + let mut cave: HashSet> = HashSet::new(); + for line in lines { + cave.extend(Cave::parse_one(line)?.iter()); + } + if cave.is_empty() { + Err(CaveError::EmptyCave) + } else { + let mut max_x = i32::MIN; + let mut min_x = i32::MAX; + let mut max_y = i32::MIN; + for block in &cave { + if block.x() < min_x { + min_x = block.x(); + } + if block.x() > max_x { + max_x = block.x(); + } + if block.y() > max_y { + max_y = block.y() + } + } + let mut map = vec![vec![false; (max_x - min_x + 1) as usize]; (max_y + 1) as usize]; + for block in cave { + map[block.y() as usize][(block.x() - min_x) as usize] = true; + } + Ok(Cave { + map, + min_x, + max_x, + height: max_y + 1, + }) + } + } + + pub fn drop_bottomless(&self) -> u32 { + let mut drops = 0; + let mut filled_map = self.map.to_vec(); + + while let Some(next) = self.drop_one(&filled_map) { + if next.y() <= self.height { + drops += 1; + self.set(&mut filled_map, next); + } else { + break; + } + } + drops + } + + fn drop_one(&self, map: &[Vec]) -> Option> { + let mut drop = Pos::new(500, 0); + loop { + let next_y = drop.y() + 1; + if next_y > self.height { + return None; + } + let mut stuck = true; + for dx in [0, -1, 1] { + let next = Pos::new(drop.x() + dx, next_y); + if !self.get(map, next) { + drop = next; + stuck = false; + break; + } + } + + if stuck { + if drop.y() == 0 { + return None; + } else { + return Some(drop); + } + } + } + } + + pub fn drop_floor(&self) -> i64 { + let last_row = self.height + 1; + let mut drops = 1; + let mut row = vec![500]; + let mut left_exceed = None; + let mut right_exceed = None; + for y in 1..last_row { + let mut next_row = Vec::new(); + for x in row { + for dx in [-1, 0, 1] { + let x = x + dx; + if x < self.min_x { + left_exceed = left_exceed.or(Some(y)); + } else if x > self.max_x { + right_exceed = right_exceed.or(Some(y)); + } else if !next_row.contains(&x) + && (y >= self.height || !self.map[y as usize][(x - self.min_x) as usize]) + { + next_row.push(x); + } + } + } + if let Some(left_exceed) = left_exceed { + if !next_row.contains(&self.min_x) && (y >= self.height || !self.map[y as usize][0]) + { + next_row.push(self.min_x); + } + drops += (y - left_exceed + 1) as i64; + } + if let Some(right_exceed) = right_exceed { + if !next_row.contains(&self.max_x) + && (y >= self.height + || !self.map[y as usize][(self.max_x - self.min_x) as usize]) + { + next_row.push(self.max_x); + } + drops += (y - right_exceed + 1) as i64; + } + drops += next_row.len() as i64; + row = next_row + } + drops + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::{common::file::read_lines, hashset}; + use anyhow::Result; + + #[test] + fn test_parse() -> Result<()> { + let input = "498,4 -> 498,6 -> 496,6"; + let expected = hashset! {Pos::new(498, 4), Pos::new(498, 5), Pos::new(498, 6), Pos::new(497, 6), Pos::new(496, 6)}; + let result = Cave::parse_one(input)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_parse_all() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let result = Cave::parse(&lines)?; + assert_eq!(result.min_x, 494); + assert_eq!(result.max_x, 503); + assert_eq!(result.height, 10); + + Ok(()) + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(24); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(93); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/day15/mod.rs b/src/days/day15/mod.rs new file mode 100644 index 0000000..0614b9e --- /dev/null +++ b/src/days/day15/mod.rs @@ -0,0 +1,317 @@ +use super::template::{DayTrait, ResultType}; +use crate::common::pos::Pos; +use itertools::Itertools; +use lazy_static::lazy_static; +use regex::Regex; +use std::{collections::HashSet, num::ParseIntError}; +use thiserror::Error; + +const DAY_NUMBER: usize = 15; + +pub struct Day; + +impl DayTrait for Day { + fn get_day_number(&self) -> usize { + DAY_NUMBER + } + + fn part1(&self, lines: &[String]) -> anyhow::Result { + let row = lines[0].parse()?; + let (sensors, beacons) = Day::parse_all(&lines[1..])?; + let result = Day::count_coverage_at(&sensors, &beacons, row); + Ok(ResultType::Integer(result)) + } + + fn part2(&self, lines: &[String]) -> anyhow::Result { + let (sensors, _) = Day::parse_all(&lines[1..])?; + let mid_lines = Day::dividing_lines(&sensors); + let points = mid_lines + .iter() + .tuple_combinations() + .filter_map(|(first, second)| first.cross(second)) + .filter(|pos| sensors.iter().all(|sensor| !sensor.contains(pos))) + .dedup() + .collect::>(); + + if points.len() != 1 { + Err(SensorError::NotExactlyOneResult(points.len()))?; + } + + let point = points.first().unwrap(); + Ok(ResultType::Integer(point.x() * 4000000 + point.y())) + } +} + +impl Day { + fn parse_all(lines: &[String]) -> Result<(HashSet, HashSet>), SensorError> { + let mut sensors = HashSet::new(); + let mut beacons = HashSet::new(); + for line in lines { + let (sensor, beacon) = Sensor::parse(line)?; + sensors.insert(sensor); + beacons.insert(beacon); + } + Ok((sensors, beacons)) + } + + fn count_coverage_at(sensors: &HashSet, beacons: &HashSet>, row: i64) -> i64 { + let ranges = sensors + .iter() + .filter_map(|sensor| sensor.range_at(row)) + .collect::>(); + let merged: i64 = Range::merge_all(&ranges) + .iter() + .map(|range| range.width()) + .sum(); + let sensors = sensors + .iter() + .filter(|sensor| sensor.pos.y() == row) + .count() as i64; + let beacons = beacons.iter().filter(|beacons| beacons.y() == row).count() as i64; + + merged - (sensors + beacons) + } + + fn dividing_lines(sensors: &HashSet) -> Vec { + sensors + .iter() + .tuple_combinations() + .filter_map(|(first, second)| Line::create(first, second)) + .collect() + } +} + +#[derive(Debug, Error)] +enum SensorError { + #[error("Not an Integer")] + NotAnInt(#[from] ParseIntError), + + #[error("Unknown line: {0}")] + UnknownLine(String), + + #[error("Did not find exactly one point for the sensor: {0}")] + NotExactlyOneResult(usize), +} + +#[derive(Debug)] +struct Line { + start: Pos, + is_up: bool, + steps: i64, +} + +impl Line { + pub fn create(first: &Sensor, second: &Sensor) -> Option { + if first.border_distance(second) != 2 { + return None; + } + + let (one, two) = if first.pos.x() < second.pos.x() { + (first, second) + } else { + (second, first) + }; + + let start; + let is_up; + if one.pos.y() < two.pos.y() { + is_up = true; + if one.pos.y() + one.radius <= two.pos.y() { + start = Pos::new(one.pos.x(), one.pos.y() + one.radius + 1); + } else { + start = Pos::new(two.pos.x() - two.radius - 1, two.pos.y()); + } + } else { + is_up = false; + if one.pos.y() - one.radius >= two.pos.y() { + start = Pos::new(one.pos.x(), one.pos.y() - one.radius - 1); + } else { + start = Pos::new(two.pos.x() - two.radius - 1, two.pos.y()); + } + } + let steps = two.pos.x().min(one.pos.x() + one.radius) - start.x(); + + Some(Line { + start, + is_up, + steps, + }) + } + + fn cross(&self, other: &Line) -> Option> { + if self.is_up == other.is_up { + return None; + } + let (bottom_up, top_down) = if self.is_up { + (self, other) + } else { + (other, self) + }; + + let r2 = + bottom_up.start.x() + bottom_up.start.y() - (top_down.start.x() + top_down.start.y()); + if r2 % 2 != 0 { + return None; + } + + let r = r2 / 2; + if r < 0 || r > top_down.steps { + return None; + } + + let pos = top_down.start + Pos::splat(r); + Some(pos) + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +struct Range(i64, i64); + +impl Range { + fn overlaps(&self, other: &Range) -> bool { + self.0 <= other.1 && other.0 <= self.1 + } + + pub fn width(&self) -> i64 { + self.1 - self.0 + 1 + } + + pub fn merge_all(ranges: &[Range]) -> Vec { + let mut ranges: Vec = ranges.iter().sorted().copied().collect(); + assert!(!ranges.is_empty()); + loop { + let mut next = vec![]; + let mut merged = false; + let mut current = ranges[0]; + for range in &ranges[1..] { + if current.overlaps(range) { + current = Range(current.0, current.1.max(range.1)); + merged = true; + } else { + next.push(current); + current = *range; + } + } + next.push(current); + + if merged { + ranges = next; + } else { + return next; + } + } + } +} + +#[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] +struct Sensor { + pos: Pos, + radius: i64, +} + +lazy_static! { + static ref SENSOR: Regex = Regex::new(r"x=(-?\d+), y=(-?\d+).*x=(-?\d+), y=(-?\d+)").unwrap(); +} + +impl Sensor { + pub fn parse(line: &str) -> Result<(Sensor, Pos), SensorError> { + let caps = SENSOR + .captures(line) + .ok_or(SensorError::UnknownLine(line.to_owned()))?; + let sensor_x = caps.get(1).unwrap().as_str().parse()?; + let sensor_y = caps.get(2).unwrap().as_str().parse()?; + let beacon_x = caps.get(3).unwrap().as_str().parse()?; + let beacon_y = caps.get(4).unwrap().as_str().parse()?; + let sensor = Pos::new(sensor_x, sensor_y); + let beacon = Pos::new(beacon_x, beacon_y); + let radius = sensor.taxicab(&beacon); + Ok(( + Sensor { + pos: sensor, + radius, + }, + beacon, + )) + } + + pub fn range_at(&self, y: i64) -> Option { + let distance = (self.pos.y() - y).abs(); + if distance > self.radius { + None + } else { + let extent = self.radius - distance; + Some(Range(self.pos.x() - extent, self.pos.x() + extent)) + } + } + + pub fn border_distance(&self, other: &Sensor) -> i64 { + let distance = self.pos.taxicab(&other.pos); + distance - self.radius - other.radius + } + + pub fn contains(&self, pos: &Pos) -> bool { + self.pos.taxicab(pos) <= self.radius + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common::file::read_lines; + use anyhow::Result; + #[test] + fn test_parse() -> Result<()> { + let input = "Sensor at x=2, y=18: closest beacon is at x=-2, y=15"; + let expected = ( + Sensor { + pos: Pos::new(2, 18), + radius: 7, + }, + Pos::new(-2, 15), + ); + let result = Sensor::parse(input)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_width() { + let sensor = Sensor { + pos: Pos::new(8, 7), + radius: 9, + }; + assert_eq!(sensor.range_at(17), None); + assert_eq!(sensor.range_at(7), Some(Range(-1, 17))); + assert_eq!(sensor.range_at(10), Some(Range(2, 14))); + } + + #[test] + fn test_merge() { + let input = vec![Range(4, 10), Range(1, 3), Range(5, 9), Range(8, 12)]; + let expected = vec![Range(1, 3), Range(4, 12)]; + assert_eq!(Range::merge_all(&input), expected); + } + + #[test] + fn test_part1() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(26); + let result = day.part1(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } + + #[test] + fn test_part2() -> Result<()> { + let day = Day {}; + let lines = read_lines(day.get_day_number(), "example01.txt")?; + let expected = ResultType::Integer(56000011); + let result = day.part2(&lines)?; + assert_eq!(result, expected); + + Ok(()) + } +} diff --git a/src/days/mod.rs b/src/days/mod.rs index 348e9be..e93a410 100644 --- a/src/days/mod.rs +++ b/src/days/mod.rs @@ -4,6 +4,15 @@ mod day03; mod day04; mod day05; mod day06; +mod day07; +mod day08; +mod day09; +mod day10; +mod day11; +mod day12; +mod day13; +mod day14; +mod day15; mod template; pub use template::DayTrait; @@ -13,7 +22,7 @@ pub mod day_provider { use super::*; use thiserror::Error; - const MAX_DAY: usize = 6; + const MAX_DAY: usize = 15; pub fn get_day(day_num: usize) -> Result, ProviderError> { match day_num { @@ -23,6 +32,15 @@ pub mod day_provider { 4 => Ok(Box::new(day04::Day)), 5 => Ok(Box::new(day05::Day)), 6 => Ok(Box::new(day06::Day)), + 7 => Ok(Box::new(day07::Day)), + 8 => Ok(Box::new(day08::Day)), + 9 => Ok(Box::new(day09::Day)), + 10 => Ok(Box::new(day10::Day)), + 11 => Ok(Box::new(day11::Day)), + 12 => Ok(Box::new(day12::Day)), + 13 => Ok(Box::new(day13::Day)), + 14 => Ok(Box::new(day14::Day)), + 15 => Ok(Box::new(day15::Day)), _ => Err(ProviderError::InvalidNumber(day_num)), } } diff --git a/src/main.rs b/src/main.rs index ff4cd7f..7e90532 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ fn output(day: usize, part: usize, result: ResultType, time: Duration) { time.as_secs_f32() ); for line in &value[1..] { - println!(" part : {line}"); + println!(" {line}"); } } ResultType::Nothing => {}