From b70c389391a6717cd744828c1ffa284f7a436459 Mon Sep 17 00:00:00 2001 From: Jort van Waes Date: Sun, 28 Jul 2024 15:31:54 +0200 Subject: [PATCH] d19p1 --- .aocf/cache/aoc2023_19.json | 14 ++++++++++++++ src/day19.rs | 11 ++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 .aocf/cache/aoc2023_19.json diff --git a/.aocf/cache/aoc2023_19.json b/.aocf/cache/aoc2023_19.json new file mode 100644 index 0000000..71fee30 --- /dev/null +++ b/.aocf/cache/aoc2023_19.json @@ -0,0 +1,14 @@ +{ + "year": 2023, + "day": 19, + "level": "second", + "title": "Aplenty", + "stars": 1, + "solution": { + "first": "348378" + }, + "input": "fmz{x<2152:R,s>3520:A,a<3391:A,A}\nqhh{a>2045:A,s>3259:A,R}\nxh{m<1065:bxz,spk}\nkmp{m>2580:R,s>3306:A,x<420:R,R}\nrdg{a<2587:md,tgj}\nmgl{a>1649:dtm,a>774:R,a<377:rlb,zth}\nsbh{a<3287:mvg,m>1668:ltf,s>1331:fp,mnq}\nngx{s>2185:A,R}\nnks{a<3191:A,A}\nvbm{s>2968:R,a>1806:R,R}\nhsz{s>2971:bvb,a<2741:R,x<2544:llm,ph}\nzkz{m<3229:A,s<157:A,s>270:R,R}\nhs{x>2050:R,a>3411:R,x<1226:A,A}\nkgf{a<2181:R,a<2345:R,A}\nfrb{m>2039:lhv,x>3596:thd,x<3416:lv,fcr}\nlv{x<3370:lrt,s>3731:zvs,A}\ndfn{s<676:ssb,x>944:cfh,R}\nbmn{a>2630:gr,a>2504:R,A}\nqzd{m>2734:R,x>697:A,kmp}\nnr{m<1287:mz,s<2707:zl,m<1677:rbf,dsf}\nzvs{x>3397:R,m>1824:R,R}\npf{a<2838:A,m<3134:A,R}\nskn{s<2806:A,a<1142:A,A}\npdh{x<1798:R,vg}\njcm{a>3565:A,m>2079:R,R}\nbkb{x>1158:A,R}\npcm{x<1851:A,m<1751:A,s>3851:A,R}\ncfh{a>3349:A,a<3006:A,A}\nrbl{m>254:lhg,a<2231:dfj,mjj}\nhcj{m<324:ch,a>3431:btv,m>619:gt,db}\nzmg{s<3391:R,A}\nqst{a<3728:bf,R}\nvb{x>1444:R,m>1765:R,A}\nkv{x>2691:A,x<2598:R,A}\nmdr{s>2816:mf,s<2801:kbc,gm}\njk{x<612:A,x>1099:R,A}\nfn{a<860:R,R}\ndc{a<2050:A,s>1982:R,A}\nncp{s>2691:R,rbm}\nzvd{s>3076:R,x>1422:A,R}\nvrt{a<2793:R,x<160:R,A}\njj{x>790:R,x<446:R,m<2015:R,A}\nzjz{x<3462:R,m<272:A,A}\nvlf{a<2738:R,fq}\nkpr{a>3349:qp,znm}\nxzb{a<2986:kq,a>3149:xvz,a>3050:gc,czx}\ngg{s<2139:A,x>1565:A,A}\ntv{a<3564:A,m<599:hjv,A}\nfvs{a<2854:R,R}\nxvs{s>1856:R,A}\npg{s>774:R,xsl}\nzxf{a<2456:A,x>2503:R,m>3721:A,A}\nqmx{s>260:R,m>495:A,s>141:R,A}\ndj{x<352:R,A}\nqlt{a>3239:flm,a<2741:qhq,cn}\nbj{a<3261:rnc,rz}\nqf{a>3523:pq,lzz}\njs{m>1214:R,x<3698:A,a>2628:hrk,lvg}\nxj{x<2614:A,s>563:A,R}\nvvv{a>2508:zvd,a<2490:A,m<3417:A,qr}\nfd{x<1479:qhh,m>571:pjp,A}\nhlm{s>998:R,R}\nkp{m<3528:R,s>1234:vdf,A}\nzl{s<2659:zr,m<1760:dqp,tlv}\nvz{x<2661:dbx,m>3637:zq,R}\ntqs{m>1877:A,s<2962:R,x<599:A,A}\nqt{m>720:A,R}\nxjt{x<2702:vsj,x>2842:A,x<2779:fn,R}\nrd{a<1509:R,R}\nfts{s>1363:R,s>531:bkb,R}\nhhv{s<1493:fbh,m>180:A,A}\nfcl{m>3590:A,x>1096:A,a>2458:A,R}\nqhq{a>2530:lj,a<2479:sb,tjc}\ntlv{s<2677:jj,m>2041:R,x<1117:qbq,rb}\njsn{x<2187:R,x>2306:A,x>2235:A,R}\ntll{a>1931:A,m>2553:A,R}\npvr{m<1861:R,a>3483:A,R}\nnbh{a<2715:A,s<3144:A,x<3691:A,R}\ngx{s<2810:R,s>2928:R,R}\nstp{a>3041:tg,a>2950:pc,vl}\nszb{x>1603:R,m<3376:A,a>3316:A,R}\nfv{s>2671:A,s<2607:A,R}\njxx{x>656:R,s<2966:R,s>2970:R,R}\ncq{x<2198:cr,a>2497:spl,bn}\ngvj{a>2538:A,s<3751:A,s<3782:R,A}\nqd{m<3240:A,a>1838:R,s<3924:A,A}\nshv{x>3654:sbb,R}\nnmj{m<1776:A,s<3321:R,m<2195:A,A}\njjh{a<3137:R,a<3237:R,A}\nrlz{s>2956:A,s<2955:A,R}\njm{m>1772:dc,m>1476:R,x<2711:R,R}\nnqp{s>3530:A,m<1333:A,A}\nhtf{s>2965:A,s<2961:rlz,s>2963:dg,tqs}\nzm{a<3051:A,s>3448:A,R}\nmc{m<959:zc,m>1897:A,R}\nln{x>3887:A,m>1127:A,m<737:A,R}\nzr{a<3138:R,x>1271:mbg,R}\nlj{x>2030:hz,x>804:qx,m>2999:ll,xx}\nssj{s<1976:A,A}\nthz{x>766:px,s>2976:tzb,x<503:kpr,mx}\nvjf{m>1878:rvx,a<3087:pp,a>3656:dj,zt}\ngf{m>1233:R,R}\ncbp{s>2758:R,a>3248:qnr,x<2255:fv,R}\nlm{m>878:R,cfl}\nvq{m<1733:A,m>1985:nb,s<993:A,jfq}\ngv{m<1633:A,sn}\nrt{s<3464:A,A}\nqjl{a>1683:R,A}\ncfl{a>2115:A,a>1855:R,m>739:A,R}\nrcd{a<3401:A,m>2007:A,A}\nlmx{s>1795:R,a<3764:R,x<2599:R,A}\ntjc{s<3432:vvv,s<3679:cq,x<2065:qm,jr}\nkd{s<403:vld,dfn}\nkf{s<3213:vbm,a>1674:A,dp}\nhfh{s>187:A,a>3393:A,A}\ncln{a>3043:gpr,m>2550:pqh,s<1070:ps,rnz}\nvp{s<2975:A,s>3013:R,s<2993:A,R}\ntdr{a>1951:kgf,A}\nqb{s<3522:zv,hr}\nrcp{m<2529:bq,s>3387:fc,lgz}\nhj{a<3013:A,R}\ndst{s>2221:A,ssj}\nvs{a>3455:A,m>1411:R,x<2959:R,A}\nzt{x<477:A,A}\nlsb{a>3616:R,A}\nzxn{a<3282:R,A}\ndsq{s>1483:R,R}\ngzh{x<2348:A,x>3307:R,x>2917:R,R}\nth{s>2362:R,a<3642:A,m>1175:A,A}\nmnz{s<2773:A,x<1683:R,m<2163:A,R}\nqfs{x>2119:st,s<2790:nr,s<2921:qkl,thz}\nxnq{x<1098:R,A}\nczl{a<3492:R,m<1520:dhn,R}\nph{a>2885:R,A}\nmpx{a>1392:A,A}\ncl{s<2801:A,R}\nhgn{m<756:R,A}\nbtm{a>2988:A,x<3864:R,m<1372:jvn,tz}\njr{x>3188:R,zck}\nls{m<2394:R,x<1213:R,m>2494:R,A}\nxd{x<2427:A,nnq}\njcr{a>967:R,x<1751:A,R}\nsn{a<3153:R,A}\nrql{m<3168:A,x>2596:R,R}\ndcr{x<1750:R,R}\nsbb{x>3775:A,m<3154:A,x>3698:A,A}\nrbm{s<2632:A,m<834:R,m<1054:R,R}\ngmc{x<3699:A,a<3675:nqp,s<3600:A,ln}\ntcn{s>1171:A,s<704:A,a>3813:R,A}\nfrz{m>2254:R,A}\nsb{m<3303:xq,a<2445:dzj,s>3171:qc,pps}\nlvg{m<937:R,A}\nmfd{m<2168:rl,vk}\nmg{s>3286:dn,s>3191:ft,x<3608:sr,qs}\nqzq{s>2669:hn,x>421:A,R}\nfpb{s>2828:A,m<1974:R,m>2023:R,R}\njn{a>3652:A,m>835:A,x>596:A,R}\nlgz{s>3091:mpx,a<1339:lk,a<1730:mm,gx}\nqjz{a<1454:hvq,qd}\nzc{a<2664:R,a>2742:R,a>2708:A,A}\nps{a>2867:A,s>585:R,tbk}\nsrj{m<3535:R,s>3566:A,a<3190:R,R}\nsk{m>1728:jnv,m<698:snk,jt}\nlzz{x>1104:nrj,m<2685:R,m>3125:A,flt}\njnv{s<1551:pg,a>1585:tdr,x<1123:qjh,cfj}\nmr{m<1914:R,R}\ncx{m>931:A,s<3493:A,x<2520:R,R}\nlrt{x>3327:A,m>1774:A,a<2780:A,A}\nhx{s>2985:R,x>1578:A,A}\ncfj{a>624:cc,s>1987:spm,A}\nmdf{m<1508:R,A}\npkp{x>2750:R,m<1095:A,a>2051:R,R}\njx{s<1021:vnh,s<1563:A,x<1053:qxb,phh}\nvg{m>3162:R,m<2522:R,A}\nzz{a<3128:lh,qb}\njp{x<1335:R,s<3280:R,A}\njzf{x>1251:rjd,xl}\nbsd{m<1264:nh,s>3470:gn,A}\nqs{x>3783:R,m>1564:A,nbh}\nsd{s>3611:xnq,bsd}\nqrh{a<3351:A,A}\nqjh{a>1016:A,R}\nmbs{s>1538:jcr,x>1578:prd,m>1097:A,vtt}\nxnb{a<2449:A,R}\nttl{x<3485:A,s<3613:R,A}\nzk{x>1459:A,R}\nqr{x<1371:R,x<2251:R,R}\nzzk{s<2054:R,blr}\njht{x>1719:qdv,x<1430:qrr,m<1821:tpp,mmv}\nll{x<276:trr,a>2636:fb,R}\nkmn{s<1306:A,R}\nlb{x<1890:R,A}\ncc{s<2128:R,m>2570:A,x<1525:A,R}\nxdp{x<2752:xj,x<2829:R,R}\npb{m>1328:A,x>3126:A,dx}\nclh{x<2549:bj,x>3292:cm,zz}\ndv{x<1801:A,A}\nnk{s<3261:A,m<3021:A,jsn}\nvnh{m<551:A,a<3426:A,x<1018:R,A}\nqnr{s>2657:A,s<2620:A,A}\nkk{x<2566:sz,m<940:A,pkp}\ngz{x>2827:A,m>1377:R,a>3844:A,R}\njf{s>3198:R,A}\nrbf{a<3435:lsv,x>1124:jl,kz}\npqh{x<3580:fgd,x<3742:R,m<3446:R,R}\nssb{s>569:R,A}\nxvz{s<3172:A,m>3249:srj,s<3675:R,A}\nvst{a<174:kqf,m<932:pr,tb}\ndz{s>3139:A,m>3016:R,s>2916:ts,A}\ncm{a>3220:nfl,s<3581:mg,m>1572:frb,fpz}\nlmd{s<531:qmx,A}\nrv{s<883:gtp,R}\nmj{a<271:vst,jmd}\nflm{a>3657:ss,m<3073:jcp,a>3460:mb,jlq}\nfhm{m>707:skz,m>428:jx,hhv}\nltf{s<1364:klc,flj}\nxzz{s<690:R,R}\nlsv{x>1230:xs,x>803:A,dmb}\nzck{m>3301:A,a<2498:R,R}\ncn{x<1403:xzb,x<2407:vd,xnx}\ngr{a<2709:R,s>3390:A,R}\nxs{a<2836:R,A}\ntx{m>2065:pjz,s<2752:R,bkd}\npl{a>1136:ntb,a>976:R,A}\njqd{a>2802:A,R}\ndp{x<3525:A,m<1550:A,A}\nst{x>2959:xv,s<2858:fxj,a>2992:xxq,pm}\ngb{s<1423:jpl,s>1892:qxv,A}\nxn{a<3097:A,m<1316:jn,R}\nmbg{s>2618:A,x>1683:A,A}\nlxd{m>3700:A,x>2578:A,a>3879:R,A}\ntrr{s>3098:R,m<3464:A,R}\ndq{m<3635:R,a<3845:tcn,kmn}\njgj{s<3138:nq,x>2896:R,cx}\nvlj{m>2155:nl,x>2944:mn,m<1230:pxs,dhj}\nbpg{x<2614:qjl,A}\nvcp{s>793:qzv,s<270:A,A}\nqdv{a>3325:R,m<1509:fx,s<2874:lb,rm}\njvn{a>2675:R,m>587:R,R}\nfb{x<533:R,x>637:A,x<601:A,A}\ntmx{x>1221:A,x>589:A,m>1573:R,A}\nchx{m<534:A,a>550:A,m<883:A,A}\ndvb{a>2690:R,m<2075:R,x<1681:A,A}\nsbg{m<1797:fhm,s<1051:kd,s>1696:xb,qf}\nsr{a>2842:xc,m>1450:qxs,xr}\npj{x<3588:R,R}\npq{m>2574:R,m<2120:R,s>1308:cfr,ls}\nbf{m<1629:R,R}\nprk{s>685:R,R}\nnnq{x<2468:A,A}\njjf{m>2326:A,x>3547:R,A}\njfq{x>3297:A,x>3146:A,m>1879:A,R}\ncb{m>3472:rt,s<3202:R,s<3720:srq,A}\nch{x>773:hpn,s>2862:dk,R}\ndn{s<3447:A,ttz}\ngpr{s<1097:A,A}\nvl{x>3762:A,A}\nmnq{m>758:dt,a<3739:xdp,lmd}\nsz{s<904:A,m>864:A,s<1117:R,R}\nmk{s<2886:R,R}\nxp{x>1234:A,pzk}\nchr{x>155:A,a<3664:R,A}\nxmr{m>2700:A,m>2605:A,A}\ndx{s<3616:A,x<2964:A,A}\njlq{m>3540:qrh,bd}\nzv{s>3247:vs,R}\nmz{x<952:qzq,a>3348:zbb,ncp}\nbg{x<3774:A,R}\nflj{s<1975:R,s>2351:jqb,s<2187:R,A}\nlr{m>2730:R,A}\ngn{s<3532:A,A}\njrz{s>3277:R,qfq}\nklc{a>3744:R,s>863:rn,A}\nvtt{s>745:A,x<1281:R,s>377:R,R}\nfgd{s<1474:R,s<1848:R,m>3506:A,R}\nnhh{a>2941:R,x>1577:A,s>3756:A,A}\nzth{a<609:R,A}\ndbx{s>3778:R,A}\njl{s<2759:zk,x>1470:R,x<1342:A,vfv}\nfp{x>2710:dsj,s>1982:qfd,s<1593:cjk,lf}\nrzc{m<1586:khl,m>1936:kst,R}\nhjv{m<388:A,m<489:R,s>1651:R,R}\ndvg{s>3895:A,a<3357:txq,m>1432:dcv,qtx}\nlk{a>744:R,s>2789:A,A}\npnt{x<1063:R,a>3752:R,A}\ntp{m<1459:A,m>1991:A,s>2990:R,A}\nxc{x>3432:A,s>3118:A,A}\npc{a<3005:A,x<3647:R,A}\nzs{s>2937:A,x<2579:R,A}\nrx{a>3530:A,x<3250:A,A}\nqm{m<3117:R,a<2507:R,R}\nkj{a<3166:A,m<3615:R,A}\nmn{m<1266:mgl,vq}\nvk{x<983:nc,x<1546:jzf,x>1984:dz,pdh}\nzg{x<2008:R,s>3072:kj,sc}\nblr{a>3400:R,R}\njbk{s<2949:R,s<2997:R,A}\ndfz{m<1517:R,rql}\nphh{m>525:A,R}\nkt{m<837:R,tmx}\nck{m<3603:A,R}\nvld{x<1330:hfh,zkz}\nqtk{x<1506:R,x>1819:vp,s<2997:mr,R}\nmgd{x<2272:sk,vlj}\nbz{m>1635:gvq,A}\nfcr{m<1877:R,s>3776:td,s>3652:fdv,ttl}\nqfq{x>2581:A,s>2888:A,R}\nmv{x>2762:R,s>3144:A,A}\ndhj{a<1461:dnt,s>1598:jm,x<2542:vmn,prk}\nnhc{m<1945:R,a>3092:fpq,s>737:A,A}\nhpk{a<3345:cln,m<2646:ddz,m<3386:pbn,dnn}\npt{x<708:R,A}\nhr{x>2940:grj,kbp}\nfq{m>2165:R,x>2581:A,x>2370:A,R}\nqfd{x>2600:A,m<762:A,th}\ngtp{a>3893:A,x<2304:R,A}\ncp{s<3476:dv,R}\ndg{x<600:R,x<702:R,A}\ndbd{x<2473:A,ngx}\nxq{m>2772:xnb,R}\ndnn{a<3753:zdk,dq}\nbch{x>1278:R,R}\nljf{s<3561:R,R}\nllm{x<2351:R,x>2443:R,a<2834:R,A}\nbn{s>3530:R,m<2950:A,x>2906:R,R}\nddz{m<977:tv,hlm}\njg{m>2428:A,R}\ndh{x<1504:A,x<1808:A,R}\nfk{x>1147:gg,R}\nvgk{x<798:pnp,zmg}\nbq{a<1202:jgj,x>3072:kf,bpg}\nxsl{m<2890:R,s<274:A,s>562:A,R}\ntl{s<3274:R,m<1126:R,a<3398:R,R}\nfpq{m>2842:R,x<2854:R,a>3172:A,A}\nxz{x<3858:R,A}\nkbc{m>1790:dh,A}\nxl{x<1082:A,R}\nvm{m>2512:ppt,x>2784:A,djd}\nhpn{a<3438:A,x>1393:A,R}\ndk{s>2898:R,x<426:R,m<148:R,R}\nfgf{x>3616:tl,x>3451:R,m>1457:nmj,R}\nqkl{m<938:hcj,x<1045:vjf,s>2836:jht,mdr}\nqxv{x<1319:R,A}\nfqq{a<692:vx,pl}\ndcv{m>2052:R,A}\njqb{x>2703:R,x<2586:R,s<2466:R,R}\nqzv{a>3126:R,A}\nrcv{a<3752:A,a>3900:A,R}\ngm{m<1858:R,a<2964:dvb,x<1488:A,A}\nntn{a>3555:R,a<3551:A,A}\nqbq{a>3358:A,s<2691:R,a<2973:R,R}\nrs{a>3320:jbk,nks}\ndtm{m>488:R,x<3512:A,m>290:R,R}\nbl{a>3316:R,s>3687:A,R}\nkc{s<3259:R,A}\nbkd{m>1890:A,A}\nlp{m<2919:A,x<3025:R,R}\nhmf{x>2254:rcp,a>1377:mfd,bxt}\nnp{a<3538:A,m>2716:A,R}\nmd{s>3917:A,m<268:R,s>3873:A,A}\ndr{m<1679:A,s<3669:A,R}\nft{x>3762:A,A}\nxx{s>3164:trn,R}\nvqh{a<2904:R,m<532:R,R}\npjp{a>1798:R,R}\nzmc{s<2881:R,s>2904:R,A}\nqqr{x<401:R,x>747:R,A}\ndpk{a>2843:A,x>3890:R,A}\nqp{x>273:A,s<2948:chr,m>1077:R,A}\nqx{a<2611:A,x>1429:R,s>3125:A,R}\nms{s>2990:A,hgn}\nhv{x<469:A,a>3710:R,R}\nxxq{m<1223:ms,a<3516:rs,qst}\nfx{m<1180:R,s>2888:A,x>1914:R,A}\nmzj{a>2632:A,s>3722:R,A}\nspl{a<2515:A,A}\nmf{a<3386:vb,a<3678:pvr,A}\nrnz{s>1644:fvs,s<1327:R,a>2795:R,mdf}\nsf{x>2740:A,m>3208:A,m>2878:R,R}\ndb{a<2768:R,A}\nckc{x>2760:A,R}\nkq{x<736:pf,m>2955:bm,x<1019:A,rk}\nmjj{s<1549:A,m<122:A,x<2583:A,R}\ndfj{x>2717:A,x<2522:R,R}\nnc{a>2039:prx,A}\ncgh{a<3531:A,R}\ntg{a<3114:R,R}\npn{x>3703:mzj,s<3689:A,a<2601:gvj,zjz}\nrnc{s>3658:xp,kt}\nrk{s<3313:A,a>2850:R,A}\nspm{x<1664:R,R}\nvj{m<1597:zs,x<2555:sh,ckc}\nvd{x<1777:bp,a<3057:nk,m<3332:hts,zg}\nvsj{a>738:R,m<564:R,x<2499:A,A}\ndjd{m>901:R,x>2691:A,m>411:A,A}\nbtv{s<2860:pnt,a<3675:zmc,s<2882:R,A}\nhf{s<3577:A,A}\ncss{x>3674:R,s<2869:A,R}\nqrr{m>1460:sgn,a<3092:A,bch}\nsnk{a>1165:fts,a>575:zh,gb}\nbp{s<3164:ctf,s<3611:zm,nhh}\nrb{s>2693:A,x>1622:R,m>1876:A,A}\nfvv{x<659:R,a<900:A,A}\nmmv{a>3301:jcm,a<2999:A,jjh}\nmx{s<2954:rzc,m>1237:htf,ks}\nqc{x>1490:zxf,ck}\nrqk{x<1761:A,s<3714:A,A}\nxb{m>2594:fk,m<2265:dst,x<868:zzk,kjb}\nknj{s>1121:R,s<500:R,a<3617:A,A}\nnts{a<3480:R,R}\nsh{a>2629:R,R}\ncgb{a<2458:R,x<463:A,A}\ndsf{x<1316:tx,hkv}\ndhn{s>3590:A,m<557:A,a<3565:R,A}\nsst{x<1814:pt,s>3481:lp,A}\nqxb{s<1990:A,m<586:A,x<589:R,A}\nin{s>2573:cff,ljt}\nppt{x<2690:A,m>3090:A,R}\nbm{x<1043:A,s>3525:R,A}\nzf{a<3590:A,s<1529:rcv,s>2106:pzg,xvs}\nzdk{x>3588:R,rx}\npzk{x>689:R,x>365:A,A}\nskz{a>3382:R,A}\nprd{s<842:A,R}\nvx{s<3173:A,a<433:hf,A}\nrlb{x<3468:A,R}\nrn{m>3010:R,A}\njt{x<1002:pcl,mbs}\nvjm{x>3738:gf,a<3342:pj,s>3730:sm,R}\nfj{x<1802:A,A}\nbd{a>3359:hs,szb}\nssq{s>3568:A,R}\nxnx{x>2986:shv,sf}\nnj{s<3783:A,A}\nfl{x>357:A,s>2954:A,x>340:A,R}\nnq{m>1667:R,m>943:R,R}\nfbh{m>161:R,m<66:A,a>3162:A,R}\ncr{s>3553:A,A}\ntd{x>3477:A,R}\nqv{a<3425:bjh,vjt}\ndl{s>2671:zxn,s>2623:R,A}\nzp{x>2382:A,s>3255:bl,A}\nbms{s>3009:R,a>3294:tp,m<1038:A,vrt}\nrpm{a<1395:R,tll}\nbk{a>3546:ntn,s<2903:gzh,m<3526:R,cgh}\ntzb{x>278:xn,bms}\nxr{x>3477:A,A}\nhts{a>3143:xf,x<2007:rkh,lz}\nbxz{s>3044:jf,a<892:chx,x<848:A,skn}\npx{m>1297:qtk,hx}\ntsb{x<3147:R,a>3771:R,knj}\ncv{s<3782:ssq,A}\nhkv{a>3352:dcr,s>2752:mnz,m>2010:hd,hj}\nprx{m>2779:R,R}\nczx{a>3022:A,a<2999:R,R}\npps{x>1404:cl,x>874:fcl,s>2774:cgb,mt}\nsg{x<2306:R,a<3800:R,A}\nkqf{s>3605:A,s>3487:A,R}\ntnt{s>3463:sg,m<3220:lr,lxd}\nhn{m>702:R,x>393:A,A}\npm{m<1297:hsz,m<1977:vj,vlf}\nntb{s>3285:A,R}\nmvg{s>1143:vm,a<2847:frz,x>2725:nhc,dfz}\nsp{a<3553:nts,a>3664:A,lsb}\nsrq{a<3602:R,x>2352:A,a>3625:R,R}\npzg{a<3836:A,R}\nfgc{a<2438:A,m<3741:R,R}\nmm{x>3140:css,m<3337:A,rd}\nsm{s<3765:R,a<3405:R,A}\nczn{x<2802:A,A}\ngvq{m>1958:R,a<1769:A,m<1786:R,A}\nttz{x<3739:A,x>3876:R,s>3519:A,A}\npr{a<237:R,m>431:R,x>1426:A,R}\ntpp{a>3182:A,a<2707:A,x>1564:qlh,mk}\ngrj{s>3751:R,R}\nkz{s>2741:A,hv}\nlhv{m<2249:R,x<3698:jjf,s<3734:xz,dpk}\nnrj{x<1806:A,R}\njmd{m>1473:R,x>1478:rqk,ljf}\nthd{s<3799:A,a<2738:A,a>2916:bg,jqd}\nnb{m>2065:A,R}\ndzj{a<2434:jp,x<2321:kc,fgc}\nxf{m<2910:A,R}\nspk{s<2869:R,a>800:R,R}\nkbp{m<1005:A,x<2696:A,R}\nxv{s>2806:bv,x<3650:qh,btm}\ntxq{x<3535:A,R}\nnl{m<2845:rpm,kp}\nngs{s>1261:A,A}\nzq{m>3877:R,x<3364:R,A}\npp{a<2724:qqr,R}\nxzq{s>3590:nj,R}\ncfr{x<848:A,R}\nlhg{m>460:A,m>326:R,A}\nbjh{x<2395:gv,s<1516:vcp,dbd}\nsgn{s>2877:R,R}\nfcf{x<2209:sbg,x>2955:hpk,x<2517:qv,sbh}\nzbb{a<3658:R,m<515:R,A}\ntb{a<218:A,a<236:R,R}\nsc{s>2865:A,a>3148:R,A}\npbn{x>3325:zf,tsb}\ncff{a<2422:hmf,m>2412:qlt,s>3063:clh,qfs}\nvmn{s<947:A,ngs}\nss{x>1459:tnt,m>3266:vgk,qzd}\nrr{s<534:A,a>3473:A,a>3368:R,R}\ntrn{m>2754:R,x>449:R,a<2611:A,A}\nhz{a<2638:mv,a<2685:A,R}\ntbk{a>2745:R,m<1366:R,s>364:A,A}\nzh{x>1134:R,fvv}\nrjd{x>1412:A,a>2038:R,A}\nlf{a>3573:lmx,x<2614:A,a>3423:A,A}\nbvb{x<2674:R,m<625:R,A}\ndqp{x<987:R,a<2998:hpr,x>1420:A,R}\nzkh{a<1561:R,m<3038:xmr,R}\nrvx{m>2093:R,s<2858:fpb,rcd}\nznm{x<319:R,m>885:R,x>386:vqh,fl}\nhvq{s>3883:A,x>2785:A,R}\nrz{x<1082:xzq,a>3651:cp,x<1650:czl,fmz}\npjz{x>538:A,A}\nqh{x<3262:dd,m<899:R,fth}\nvdf{a>1051:A,x>3294:A,R}\nfpz{a>2815:stp,m>701:js,s<3832:pn,rdg}\nkst{a<3094:A,m>2135:R,x<672:A,A}\nqtx{m>683:R,s<3833:R,A}\nfxj{x<2467:cbp,dl}\npsb{m<1388:R,m>1544:A,A}\npxs{a<1718:xjt,m<643:rbl,s>1421:lm,kk}\nljt{a>2624:fcf,mgd}\nnfl{a>3489:gmc,s<3641:fgf,s<3792:vjm,dvg}\nfc{x>3056:cv,s>3793:qjz,zkh}\nmt{m>3668:A,R}\nhpr{x>1718:A,R}\nflt{a>3075:A,a>2908:A,R}\nctf{x>1609:A,R}\ndsj{a<3751:R,m>907:gz,czn}\nbv{s>2915:R,A}\ntz{m<1810:A,a<2686:A,R}\nmb{a>3565:cb,a<3520:jrz,s<3371:bk,vz}\nvjt{x>2364:xd,a>3766:rv,m>1489:dsq,sp}\nqxs{x<3426:R,s<3113:A,s<3164:R,R}\nmqk{x>667:R,m<172:R,A}\nrl{m<1092:fd,x>1086:lhn,bz}\nfdv{m>1942:R,A}\nrm{m>1957:A,A}\nlhn{s<3198:R,s<3592:A,s<3775:dr,pcm}\nhd{a<2845:R,s<2732:R,R}\njpl{a>264:R,A}\nvfv{s<2778:A,R}\nks{m<457:mqk,jxx}\nfth{a<2956:A,R}\ndt{x>2769:A,a>3731:R,rr}\nkhl{s>2935:R,s<2926:A,x<592:R,A}\ndd{m>876:A,a<3338:A,s>2716:A,A}\npcl{m>1041:psb,A}\nknd{m<2644:fj,x>2165:np,R}\ngt{m<827:qt,x<929:R,A}\ncjk{a<3687:A,m>647:R,m<243:R,R}\njcp{m>2784:sst,a<3426:zp,knd}\ntgj{m<337:R,a>2693:R,R}\nnh{m>555:R,A}\nlh{x>2825:pb,a>2849:kv,x<2675:mc,bmn}\ndmb{x>421:R,R}\nkjb{x>1695:jg,A}\ndnt{s>1307:A,m<1721:xzz,s>494:R,R}\npnp{a<3835:R,x<438:A,a>3901:R,R}\nhrk{m>916:R,m<842:R,s<3857:A,R}\nqlh{a>2916:R,A}\ngc{s<3185:R,s<3485:jk,s<3827:A,R}\nts{m<2719:A,s<3037:R,a>2063:A,A}\nbxt{m>2226:fqq,s<3295:xh,a>494:sd,mj}\nlz{s<3205:R,A}\nrkh{s>3298:R,a<3086:R,s>2875:A,A}\n\n{x=53,m=706,a=908,s=10}\n{x=518,m=1763,a=669,s=832}\n{x=745,m=1031,a=529,s=1094}\n{x=92,m=724,a=1146,s=1}\n{x=221,m=945,a=188,s=280}\n{x=225,m=1271,a=1124,s=311}\n{x=2080,m=834,a=2731,s=93}\n{x=293,m=22,a=1850,s=1550}\n{x=166,m=67,a=2239,s=785}\n{x=2479,m=198,a=600,s=11}\n{x=496,m=696,a=1081,s=47}\n{x=128,m=1915,a=822,s=290}\n{x=2287,m=411,a=1959,s=551}\n{x=661,m=1318,a=1169,s=1799}\n{x=250,m=2851,a=113,s=142}\n{x=2334,m=166,a=383,s=1021}\n{x=668,m=815,a=194,s=1103}\n{x=651,m=258,a=2192,s=2322}\n{x=1170,m=1099,a=235,s=1183}\n{x=1901,m=1337,a=1672,s=1234}\n{x=3,m=424,a=3285,s=2127}\n{x=213,m=223,a=1549,s=196}\n{x=2729,m=1952,a=392,s=524}\n{x=26,m=790,a=1913,s=765}\n{x=546,m=607,a=218,s=68}\n{x=131,m=895,a=837,s=1086}\n{x=274,m=808,a=2483,s=1090}\n{x=1682,m=2367,a=3375,s=446}\n{x=258,m=717,a=1109,s=2045}\n{x=581,m=1334,a=2265,s=422}\n{x=410,m=2743,a=3308,s=305}\n{x=542,m=2556,a=1104,s=1774}\n{x=195,m=1205,a=120,s=571}\n{x=1613,m=816,a=1180,s=606}\n{x=512,m=3,a=2,s=713}\n{x=8,m=251,a=159,s=1830}\n{x=659,m=921,a=343,s=1642}\n{x=412,m=1227,a=1098,s=3350}\n{x=376,m=1165,a=1162,s=1524}\n{x=113,m=643,a=356,s=406}\n{x=1544,m=18,a=2845,s=1447}\n{x=692,m=2900,a=49,s=125}\n{x=1549,m=1257,a=2565,s=475}\n{x=433,m=1155,a=1206,s=746}\n{x=301,m=1527,a=89,s=1344}\n{x=2264,m=1514,a=290,s=747}\n{x=397,m=1052,a=725,s=1329}\n{x=97,m=695,a=1213,s=1915}\n{x=1740,m=3424,a=97,s=3028}\n{x=211,m=1826,a=44,s=299}\n{x=725,m=3005,a=221,s=68}\n{x=1061,m=1058,a=247,s=701}\n{x=615,m=1968,a=75,s=2522}\n{x=60,m=320,a=340,s=2586}\n{x=157,m=1847,a=1349,s=298}\n{x=3438,m=695,a=2623,s=801}\n{x=1775,m=551,a=344,s=211}\n{x=2311,m=5,a=2269,s=1867}\n{x=914,m=199,a=983,s=846}\n{x=1035,m=1873,a=1040,s=2527}\n{x=1276,m=706,a=542,s=118}\n{x=1980,m=3487,a=266,s=405}\n{x=1661,m=153,a=1083,s=935}\n{x=333,m=2639,a=162,s=1149}\n{x=502,m=456,a=1803,s=8}\n{x=498,m=971,a=12,s=135}\n{x=1031,m=1045,a=169,s=409}\n{x=815,m=1124,a=1956,s=222}\n{x=870,m=792,a=593,s=982}\n{x=821,m=644,a=5,s=79}\n{x=709,m=1023,a=2115,s=1823}\n{x=1446,m=1261,a=1343,s=940}\n{x=156,m=2366,a=1235,s=143}\n{x=15,m=154,a=879,s=2009}\n{x=1815,m=1095,a=396,s=119}\n{x=166,m=383,a=1926,s=371}\n{x=2006,m=2490,a=491,s=1612}\n{x=2936,m=735,a=160,s=756}\n{x=1145,m=921,a=668,s=67}\n{x=3256,m=2353,a=672,s=235}\n{x=3,m=1727,a=1889,s=608}\n{x=137,m=18,a=820,s=899}\n{x=1495,m=356,a=32,s=3077}\n{x=223,m=535,a=1169,s=290}\n{x=491,m=1384,a=2760,s=1715}\n{x=24,m=441,a=352,s=428}\n{x=2045,m=342,a=2921,s=3447}\n{x=352,m=1975,a=1086,s=740}\n{x=685,m=1759,a=619,s=3086}\n{x=172,m=3238,a=2573,s=1739}\n{x=342,m=311,a=770,s=1594}\n{x=482,m=960,a=357,s=3234}\n{x=129,m=8,a=1302,s=1683}\n{x=2582,m=584,a=2405,s=2935}\n{x=1139,m=3043,a=735,s=1128}\n{x=1665,m=2277,a=272,s=915}\n{x=472,m=2355,a=2508,s=285}\n{x=137,m=571,a=1995,s=3237}\n{x=2529,m=2131,a=459,s=587}\n{x=403,m=111,a=1923,s=757}\n{x=1539,m=278,a=2723,s=422}\n{x=419,m=650,a=736,s=2491}\n{x=5,m=71,a=885,s=445}\n{x=961,m=933,a=811,s=2442}\n{x=197,m=1327,a=2544,s=543}\n{x=629,m=1585,a=911,s=2727}\n{x=195,m=162,a=615,s=37}\n{x=409,m=2857,a=678,s=2310}\n{x=29,m=422,a=311,s=477}\n{x=2644,m=1270,a=2536,s=221}\n{x=255,m=2447,a=1433,s=1231}\n{x=822,m=2110,a=528,s=1246}\n{x=87,m=2524,a=478,s=38}\n{x=1461,m=489,a=87,s=1821}\n{x=694,m=1612,a=1056,s=241}\n{x=725,m=1007,a=1867,s=33}\n{x=482,m=1282,a=110,s=926}\n{x=392,m=716,a=684,s=95}\n{x=29,m=683,a=1294,s=681}\n{x=594,m=1878,a=2117,s=33}\n{x=488,m=1058,a=187,s=2150}\n{x=76,m=1020,a=1571,s=1224}\n{x=2675,m=353,a=223,s=41}\n{x=115,m=1165,a=1346,s=307}\n{x=1249,m=527,a=703,s=2603}\n{x=1803,m=1667,a=50,s=226}\n{x=193,m=520,a=77,s=761}\n{x=2917,m=936,a=1966,s=2314}\n{x=388,m=15,a=3355,s=742}\n{x=3258,m=97,a=961,s=2108}\n{x=44,m=508,a=63,s=1369}\n{x=2669,m=1486,a=917,s=2768}\n{x=78,m=3505,a=2201,s=36}\n{x=270,m=831,a=2645,s=348}\n{x=4,m=1432,a=271,s=1574}\n{x=96,m=100,a=1797,s=545}\n{x=2625,m=93,a=662,s=178}\n{x=71,m=1386,a=1805,s=1039}\n{x=342,m=907,a=1556,s=1712}\n{x=1152,m=524,a=1207,s=586}\n{x=441,m=1274,a=1282,s=1374}\n{x=1701,m=103,a=420,s=2658}\n{x=223,m=120,a=1099,s=1186}\n{x=852,m=10,a=1380,s=1136}\n{x=3087,m=50,a=1648,s=1805}\n{x=569,m=1578,a=330,s=52}\n{x=2011,m=284,a=141,s=332}\n{x=321,m=1488,a=95,s=1524}\n{x=678,m=145,a=2229,s=167}\n{x=1971,m=198,a=1405,s=278}\n{x=3075,m=833,a=1836,s=688}\n{x=718,m=176,a=1943,s=3507}\n{x=1136,m=20,a=752,s=1663}\n{x=425,m=939,a=106,s=546}\n{x=24,m=88,a=2692,s=1980}\n{x=738,m=919,a=2233,s=389}\n{x=1955,m=517,a=191,s=596}\n{x=186,m=1864,a=3163,s=325}\n{x=294,m=2125,a=595,s=2345}\n{x=320,m=591,a=385,s=335}\n{x=468,m=307,a=1674,s=1166}\n{x=1291,m=1508,a=231,s=758}\n{x=715,m=2147,a=485,s=1376}\n{x=386,m=236,a=190,s=190}\n{x=261,m=1774,a=140,s=3186}\n{x=711,m=1599,a=895,s=496}\n{x=658,m=394,a=11,s=375}\n{x=1847,m=2236,a=2044,s=715}\n{x=497,m=1462,a=548,s=1383}\n{x=584,m=124,a=1655,s=1728}\n{x=115,m=1486,a=101,s=200}\n{x=20,m=1103,a=1861,s=704}\n{x=1544,m=1439,a=1077,s=1119}\n{x=132,m=18,a=345,s=2717}\n{x=2454,m=1455,a=991,s=66}\n{x=1581,m=1343,a=94,s=26}\n{x=1495,m=664,a=20,s=671}\n{x=99,m=1846,a=2815,s=898}\n{x=583,m=1588,a=2102,s=1799}\n{x=266,m=59,a=267,s=683}\n{x=2885,m=955,a=691,s=1786}\n{x=346,m=74,a=490,s=1126}\n{x=1044,m=806,a=388,s=8}\n{x=73,m=80,a=975,s=281}\n{x=132,m=1041,a=544,s=734}\n{x=346,m=1693,a=501,s=185}\n{x=827,m=1183,a=385,s=140}\n{x=94,m=304,a=216,s=398}\n{x=67,m=576,a=76,s=1267}\n{x=1642,m=52,a=50,s=1308}\n{x=2551,m=746,a=3136,s=455}\n{x=291,m=1112,a=1445,s=472}\n{x=388,m=292,a=82,s=3715}\n{x=2849,m=52,a=1385,s=926}\n{x=948,m=891,a=912,s=687}\n{x=984,m=3303,a=1191,s=3152}\n{x=74,m=1770,a=744,s=689}\n{x=273,m=427,a=774,s=451}\n{x=86,m=3295,a=830,s=548}\n{x=1475,m=2237,a=984,s=147}\n", + "brief": { + "first": "The Elves of Gear Island are thankful for your help and send you on your way. They even have a hang glider that someone [stole](9) from Desert Island; since you're already going that direction, it would help them a lot if you would use it to get down there and return it to them.\n\nAs you reach the bottom of the *relentless avalanche of machine parts*, you discover that they're already forming a formidable heap. Don't worry, though - a group of Elves is already here organizing the parts, and they have a *system*.\n\nTo start, each part is rated in each of four categories:\n\n* `x`: E*x*tremely cool looking\n* `m`: *M*usical (it makes a noise when you hit it)\n* `a`: *A*erodynamic\n* `s`: *S*hiny\n\nThen, each part is sent through a series of *workflows* that will ultimately *accept* or *reject* the part. Each workflow has a name and contains a list of *rules*; each rule specifies a condition and where to send the part if the condition is true. The first rule that matches the part being considered is applied immediately, and the part moves on to the destination described by the rule. (The last rule in each workflow has no condition and always applies if reached.)\n\nConsider the workflow `ex{x>10:one,m<20:two,a>30:R,A}`. This workflow is named `ex` and contains four rules. If workflow `ex` were considering a specific part, it would perform the following steps in order:\n\n* Rule \"`x>10:one`\": If the part's `x` is more than `10`, send the part to the workflow named `one`.\n* Rule \"`m<20:two`\": Otherwise, if the part's `m` is less than `20`, send the part to the workflow named `two`.\n* Rule \"`a>30:R`\": Otherwise, if the part's `a` is more than `30`, the part is immediately *rejected* (`R`).\n* Rule \"`A`\": Otherwise, because no other rules matched the part, the part is immediately *accepted* (`A`).\n\nIf a part is sent to another workflow, it immediately switches to the start of that workflow instead and never returns. If a part is *accepted* (sent to `A`) or *rejected* (sent to `R`), the part immediately stops any further processing.\n\nThe system works, but it's not keeping up with the torrent of weird metal shapes. The Elves ask if you can help sort a few parts and give you the list of workflows and some part ratings (your puzzle input). For example:\n\n```\npx{a<2006:qkq,m>2090:A,rfg}\npv{a>1716:R,A}\nlnx{m>1548:A,A}\nrfg{s<537:gd,x>2440:R,A}\nqs{s>3448:A,lnx}\nqkq{x<1416:A,crn}\ncrn{x>2662:A,R}\nin{s<1351:px,qqz}\nqqz{s>2770:qs,m<1801:hdj,R}\ngd{a>3333:R,R}\nhdj{m>838:A,pv}\n\n{x=787,m=2655,a=1222,s=2876}\n{x=1679,m=44,a=2067,s=496}\n{x=2036,m=264,a=79,s=2244}\n{x=2461,m=1339,a=466,s=291}\n{x=2127,m=1623,a=2188,s=1013}\n\n```\n\nThe workflows are listed first, followed by a blank line, then the ratings of the parts the Elves would like you to sort. All parts begin in the workflow named `in`. In this example, the five listed parts go through the following workflows:\n\n* `{x=787,m=2655,a=1222,s=2876}`: `in` -\\> `qqz` -\\> `qs` -\\> `lnx` -\\> `*A*`\n* `{x=1679,m=44,a=2067,s=496}`: `in` -\\> `px` -\\> `rfg` -\\> `gd` -\\> `*R*`\n* `{x=2036,m=264,a=79,s=2244}`: `in` -\\> `qqz` -\\> `hdj` -\\> `pv` -\\> `*A*`\n* `{x=2461,m=1339,a=466,s=291}`: `in` -\\> `px` -\\> `qkq` -\\> `crn` -\\> `*R*`\n* `{x=2127,m=1623,a=2188,s=1013}`: `in` -\\> `px` -\\> `rfg` -\\> `*A*`\n\nUltimately, three parts are *accepted*. Adding up the `x`, `m`, `a`, and `s` rating for each of the accepted parts gives `7540` for the part with `x=787`, `4623` for the part with `x=2036`, and `6951` for the part with `x=2127`. Adding all of the ratings for *all* of the accepted parts gives the sum total of `*19114*`.\n\nSort through all of the parts you've been given; *what do you get if you add together all of the rating numbers for all of the parts that ultimately get accepted?*\n\nYour puzzle answer was `348378`.\n\nThe first half of this puzzle is complete! It provides one gold star: \\*\n\n\\--- Part Two ---\n----------\n\nEven with your help, the sorting process *still* isn't fast enough.\n\nOne of the Elves comes up with a new plan: rather than sort parts individually through all of these workflows, maybe you can figure out in advance which combinations of ratings will be accepted or rejected.\n\nEach of the four ratings (`x`, `m`, `a`, `s`) can have an integer value ranging from a minimum of `1` to a maximum of `4000`. Of *all possible distinct combinations* of ratings, your job is to figure out which ones will be *accepted*.\n\nIn the above example, there are `*167409079868000*` distinct combinations of ratings that will be accepted.\n\nConsider only your list of workflows; the list of part ratings that the Elves wanted you to sort is no longer relevant. *How many distinct combinations of ratings will be accepted by the Elves' workflows?*\n\nAnswer:\n\nAlthough it hasn't changed, you can still [get your puzzle input](19/input)." + } +} \ No newline at end of file diff --git a/src/day19.rs b/src/day19.rs index 412887a..19e1cd8 100644 --- a/src/day19.rs +++ b/src/day19.rs @@ -137,7 +137,7 @@ impl Rule { fn apply(&self, part: &mut Part) { let new_part = (self.rule)(part.clone()); if new_part.workflow != part.workflow { - debug!(true, "{:?} + {:?} == {:?}", part, self, new_part); + debug!(false, "{:?} + {:?} == {:?}", part, self, new_part); } *part = new_part; } @@ -168,7 +168,7 @@ impl System { fn process(mut self) -> System { for p in &mut self.parts { - debug!(true, "{:#?}", &p); + debug!(false, "{:#?}", &p); while !(p.workflow == "R" || p.workflow == "A") { debug!(false, "{:?}", &p); let w: &Workflow = self @@ -176,7 +176,7 @@ impl System { .iter() .find(|w| w.name == p.workflow) .unwrap(); - debug!(true, "{:?}", &w); + debug!(false, "{:?}", &w); for rule in &w.rules { rule.apply(p); if p.workflow != w.name { @@ -230,4 +230,9 @@ fn main() { test!("A", system.parts[4].workflow); let sum = system.sum_of_accepted_parts(); test!(19114, sum); + //Part 1 + let sum = System::from_workflows_and_parts(&aoc::get(2023, 19)) + .process() + .sum_of_accepted_parts(); + test!(348378, sum); }