diff --git a/Advent2023/Data/Day19.txt b/Advent2023/Data/Day19.txt new file mode 100644 index 0000000..99cbf44 --- /dev/null +++ b/Advent2023/Data/Day19.txt @@ -0,0 +1,771 @@ +bz{a<271:A,R} +tq{s<1378:A,x>1056:A,x<975:A,R} +sxl{s>1993:R,A} +sp{s<2096:R,s<2187:A,s<2282:R,tk} +dbt{a>2090:R,m>2213:A,A} +lcc{x>3562:R,m>3519:R,a<1652:R,R} +vq{x>2087:tp,cct} +ljp{x<1547:jf,m<272:ll,m>384:qm,bzs} +xl{s>1785:jdc,a<1017:jpk,s>1221:jzs,czl} +vll{a<3176:A,a<3698:R,R} +sq{x<2664:A,R} +dmz{s>1569:hnt,a<2542:dbj,x<930:zms,rn} +zs{a>1300:R,x<3562:R,x>3761:A,A} +vdp{x>1906:kpk,x>1169:R,A} +jpv{s<922:R,m<2767:A,s<1020:A,R} +tth{m<2502:R,s<569:A,s>755:R,R} +vcd{m>3139:dmz,x>1052:vd,a<2027:qhl,kt} +zdn{s<1724:jrf,hm} +vgq{a<3115:A,x<335:R,R} +qf{a<3351:A,a<3753:A,m>111:A,dbk} +mfg{m>2121:R,a<2902:A,m<2043:A,R} +bxp{s>3412:A,m<2753:A,R} +nxn{x<672:A,m>2353:A,R} +hpr{a>1842:A,a>728:hcz,x>1243:A,A} +cvl{a>669:mjv,m>2629:sc,rdf} +kxx{a>766:R,a<292:R,A} +dmg{s>2102:A,s>2014:A,A} +rgv{a<3593:A,A} +chn{a>2598:cbs,s>174:A,a<2260:tx,R} +xz{m<1473:A,x>3212:R,x<2650:A,R} +gzf{x>339:R,s>2706:R,A} +zsr{a>3599:R,m>3283:R,s<1003:R,A} +kc{m>1743:A,a>1102:R,x<2016:A,A} +fns{s>2718:R,m<250:R,zz} +rks{x>1085:A,a<3193:R,R} +tsb{x>2609:R,R} +jpk{a<367:lmr,lkr} +zt{x<728:A,x<1273:A,x<1612:A,R} +sm{s<2016:R,m>3494:R,R} +lqv{x>2509:rgv,mdj} +qgc{s<2535:A,A} +mn{x>711:R,R} +qj{m<2321:A,a>1060:A,m<2640:A,A} +lvl{x>2318:R,x>1150:R,R} +fvj{x>629:xm,m>434:tg,R} +drm{x>3363:A,s<67:A,m<966:A,A} +hc{a>2875:R,a<2355:R,A} +rzh{x<2577:rt,a<1217:zjs,a<1672:A,xt} +bcf{m<75:tm,s>2347:A,cjj} +xsd{m<124:A,s>2385:A,bsn} +dx{m<1166:R,A} +csf{s<815:sxq,a<2075:dck,ndb} +dt{s<3903:R,a>3046:R,A} +xbj{a<2484:bp,x>3289:rfz,s>239:vs,xs} +jmg{a<3045:pxt,lp} +mpz{x<1593:R,x>3044:R,a<3808:A,A} +lhp{x>1339:R,s<2653:A,x>649:R,A} +ll{s<3281:R,A} +dcq{x>3360:R,m<3027:R,R} +ppg{m<541:R,m>559:R,x<2390:R,R} +mbz{m<3495:R,s>2446:rks,A} +cd{m<1335:A,m>1438:A,R} +krc{x<733:mfg,a>2761:qh,x>953:dch,zp} +lvg{m>972:kz,x>495:hzn,a>3117:A,A} +zhs{m>2206:rf,a<835:A,a>1165:R,R} +fsh{x>2167:A,s>849:R,R} +kbr{m<611:cpv,dp} +rmx{a<1561:rs,s<1865:vq,m<710:tbz,fvq} +hnh{s<2247:A,s>2348:R,m<339:R,R} +hzq{m>626:A,a<2948:A,s<2726:A,R} +rx{s<2136:A,s<2240:R,m>2747:A,R} +qm{m>429:A,a>2633:dzg,a>2161:A,R} +sbn{m<3741:R,m<3839:A,s<1462:A,R} +lpk{s<3389:R,A} +pxt{a>2883:hzq,zh} +fvq{s>2926:dvb,vmx} +rz{s>425:md,s<168:pn,R} +hxn{x>439:R,a<1407:A,A} +qpg{m>3129:R,R} +pb{a>1824:vzm,x>3183:spc,qmb} +dvj{a>925:R,s<234:A,R} +ksm{m>1071:A,m<396:A,s<327:A,R} +qd{m>2276:R,s<225:R,x>3486:R,R} +jzs{m<2895:prh,s<1539:R,a>1512:ktn,zs} +dp{x<1710:A,m<665:R,a>3405:R,R} +fnf{s>2544:A,m<2240:R,A} +fk{a>767:A,m<2071:R,R} +ndq{x<581:vr,a>2446:qjm,s>2111:jl,dhs} +kkl{s>2054:R,m<3499:R,m<3761:R,cjk} +xtv{a>1875:A,x>3752:R,m<2351:A,A} +xpf{s<1203:nr,m<3594:vn,x<2455:A,sbn} +hfx{a<1359:R,s<449:A,s>777:R,A} +mrm{a>1753:tpl,x>1066:zzk,glm} +nxx{s>2462:gxf,jz} +qsf{a>2892:R,A} +xt{s<1927:R,s<2188:A,a>1886:A,A} +vbm{a<1287:A,xsj} +cdh{a>2648:dq,vtq} +jc{m>2325:R,x<465:A,m>2139:A,R} +zzk{a>1062:xg,m>3439:vf,lg} +fvl{s>3488:R,a<3070:A,A} +kdk{m>2643:gl,qd} +bhd{x>1591:R,a<3099:R,R} +jdc{s<2074:dsl,m<2676:gc,A} +gz{x>960:A,vgq} +ps{m>337:A,A} +clf{s<1430:ct,nk} +bsn{a<2452:R,s<2072:A,a<2687:A,A} +fjr{s>918:zsr,m<2877:A,R} +bx{m>3430:R,A} +zg{m>1485:A,s>2852:A,m<1298:R,jrq} +lp{x<1690:A,s>2595:R,x>2670:A,R} +qmb{x<2671:lnl,s>696:R,A} +jk{s<1930:R,x<2990:R,R} +lx{a<2583:dz,mbc} +pkq{s<368:R,s>527:R,a>3711:A,R} +rzl{m>1462:A,s<2457:A,s<2597:R,R} +tgr{a>2640:R,R} +pj{x>2209:xp,a>2278:A,mt} +lmr{s>1359:R,x<3503:R,A} +nq{x>1084:R,x>478:R,A} +ndb{a>3110:ss,x>3077:gmd,s<1734:fn,js} +vpg{x<706:fdp,a>852:hfx,a<542:A,A} +gxn{a<312:lsk,x>2287:dj,A} +tcl{a>1665:A,zzr} +sjk{x>3226:A,A} +fkb{m>2795:jk,a<3439:jq,x>3038:R,bzr} +pl{m<1045:A,s<3912:A,x<2819:A,R} +hhj{a>2420:R,s<2764:R,a<2288:R,A} +sqb{s>1984:rx,R} +qbd{m>2065:A,x<882:A,m<1999:R,A} +gxv{m>595:R,a>3447:ppg,x<2625:R,fpx} +bf{a<3541:R,drm} +zjs{s<1967:R,s>2205:R,R} +cct{s<720:hj,jqg} +sqr{s<815:R,m>3766:R,s>962:A,A} +dsl{a<888:A,m>3114:A,R} +hg{a<3188:A,a<3272:A,R} +gn{m<348:A,a>3297:R,A} +crq{m<369:cdk,x>1901:lh,gz} +zzr{a>1577:R,s<2759:A,s>2978:A,R} +sdq{s<2531:ft,nbf} +cx{s<2002:A,A} +zch{m<3110:A,a<580:R,A} +jm{a>3202:A,tth} +tpl{m<3521:rp,s<417:chn,vgg} +lsk{s<2835:A,a<146:A,A} +kt{s>1824:gj,m<2677:jxf,gcz} +vdb{s<2725:R,A} +krk{m>1118:A,x>3794:A,s<2745:A,A} +hx{s>3398:R,s<3375:R,x<1299:A,A} +mbc{x<3258:R,a>3221:R,x>3540:A,dcq} +bcq{s<707:vvf,m<463:rv,A} +vf{x<1370:R,s<575:A,sqr} +mk{m>2037:tfj,x>1441:A,s<2719:A,A} +ktn{a>1844:R,x<3658:A,s>1639:A,R} +hkh{s<3644:qnf,a>2509:R,a<2158:jg,sj} +qkb{s>221:A,A} +nbf{x>1635:A,R} +ktf{s<1930:jff,a>729:sv,s<2195:R,R} +tbz{s>3054:hjn,m<295:ts,m>474:sf,rtk} +rg{a>2237:A,s>2763:R,R} +tn{s<2624:mq,vdp} +zx{s<2597:R,R} +hp{s>3853:dt,s<3725:nss,tgr} +kkh{a>2790:R,m>189:A,R} +pmb{m<257:R,R} +tx{s>78:R,a>2050:R,R} +zhq{a>1619:A,x<2261:R,R} +qh{m>2162:R,m>2032:A,R} +sfh{s>3658:R,A} +xs{x<2780:R,A} +mv{a<2521:hd,gxv} +zl{x>2215:cd,m>1293:hq,xv} +qc{s<1635:A,A} +vb{x>631:vkd,s>2815:xn,s>2755:A,gzf} +lv{s>3494:A,A} +lj{a<2530:A,m>36:R,A} +kz{x>572:R,a<2969:R,A} +pnb{m<81:ljx,xsd} +rv{s>1327:A,A} +nkl{x>2711:R,x>2565:R,A} +dkn{a<1500:pfp,x>1968:dtr,cpb} +sz{m<2803:cfx,mbz} +vm{s>3556:xtv,fg} +vqr{a<2337:A,s>2233:R,R} +ss{s>1468:fkb,s<1048:fjr,x<3082:qfl,cjz} +fp{a>2830:A,s<2169:R,R} +rjr{m>1228:R,R} +kl{a>644:A,R} +zlb{x<1411:qf,a>3522:bcf,nxx} +ckr{m<2196:qbd,x>784:R,mxv} +hb{m>2153:R,R} +nml{x<1589:qv,sxk} +qr{m<2677:A,s>2608:R,m<3452:A,A} +jh{s>1262:glg,m>2684:A,R} +kh{m>2680:A,m>2361:R,A} +vr{x<257:R,xhv} +hjn{m>467:mv,s>3603:hp,ljp} +fq{m>2822:tv,x<2595:nml,x<3261:tt,rfp} +vtq{x>2240:xz,s>3083:A,dh} +gb{s<2899:bz,tb} +mrd{x>1271:lr,m<2641:rm,x<526:zqr,fs} +mld{a>2486:A,x>3111:R,m<316:A,R} +hcc{a<1236:A,a<1350:A,zlx} +fs{s>603:R,A} +cjz{a>3524:R,fjh} +pjk{a<2164:R,s<3627:R,x<2770:A,A} +mxv{x<464:A,R} +mjv{a>987:xhn,vtt} +pfc{s<3515:R,m<2266:A,s<3692:R,A} +tz{m>914:kkg,a<2667:rng,x<1472:rq,gn} +qhl{s<1607:jkc,a>1133:mds,nt} +qg{s>1998:R,x<2415:A,R} +dl{s<2694:ghj,x>2629:xpd,lqs} +vgg{a>2972:R,zt} +vqd{s>1429:A,x>354:A,A} +qfh{s>3793:xpb,x<2138:hkh,a>2637:vg,hv} +vmx{s>2326:dl,x>1382:dpd,m>1421:ndq,vrf} +xsj{m>2720:R,a<1313:R,a>1330:A,R} +nps{a<2079:R,m>1380:R,a>2173:kf,A} +kxp{m<1582:A,A} +jln{m<1242:A,a<2086:R,a>2252:A,A} +tfj{a>392:R,x>1464:A,x<774:R,R} +ghj{m<1275:vnz,m<1584:rzl,m<1710:hc,lvl} +jmb{s>2167:R,s>2124:R,R} +jg{x<1043:R,R} +gc{m>2288:R,x>3485:R,A} +lch{m>981:A,x<307:A,A} +dch{m<2204:R,a>2068:R,R} +fj{a<855:zg,gvv} +hv{m>1308:pjk,a>1953:R,m>961:R,sfh} +tv{a<1389:ctq,pj} +qt{m>3033:ktf,m>2364:sqb,rzh} +dhs{m<1658:A,s>1977:sft,x>884:R,xdl} +bld{x<2869:A,R} +lh{m<436:dbl,a<2712:lq,m>457:A,A} +hvh{s<242:R,m>1756:hqt,x<1329:A,dzs} +zb{x<902:R,s>341:A,s<172:A,R} +md{a>3376:R,R} +zlx{s<733:A,R} +xcl{a>870:A,m>3355:A,a<455:R,R} +vmn{s<2480:A,R} +hqt{a<526:A,m>1813:A,R} +tnp{s<1812:R,bgn} +ljx{x<2542:lhp,lj} +pg{x<1652:R,R} +vd{x<1464:hpr,x<1655:tnp,sxn} +zh{m>578:A,a<2830:A,R} +dzs{x>1651:A,A} +sj{s<3698:R,m<1133:A,A} +ks{a>1809:A,R} +xpb{x<1450:R,m>1232:zq,pl} +ffg{x>2163:lt,s>3351:hx,x>786:qnr,lch} +dnn{m<2585:R,A} +gmd{x<3605:zdn,gct} +jq{x<2628:A,A} +cpv{s<2035:R,R} +gct{x<3764:A,x>3852:R,a>2497:hl,A} +vlc{x>2214:A,s<3472:R,s>3806:A,A} +bvl{m<2738:R,R} +vxf{m<3019:A,x<3541:A,A} +tg{a<3439:R,s<2677:R,R} +fsf{a>2519:A,R} +pv{a<420:A,m>1733:A,R} +fff{a>2742:A,x>3397:A,A} +lb{s<2419:A,s<2498:R,a<1250:A,R} +gfp{x>3062:A,A} +cjj{a>3731:R,A} +dqf{s<2041:R,a<2123:A,vpk} +pc{x<2498:R,s>2942:A,R} +psb{m<380:A,m<422:rjp,R} +xhn{m<2996:qj,a>1071:cn,a<1022:R,hgp} +pt{a<2754:nkl,A} +zjz{a<734:A,R} +pm{x<1100:A,m>2655:R,a>3140:R,A} +rdf{m>2278:gxn,x>2317:cvv,mk} +dts{x>1531:pg,a<3446:vj,m>1041:kq,pkq} +dck{x>3214:xl,s>1666:qt,nsj} +lc{x>361:A,A} +kkg{m>1303:A,a<2452:A,x<1273:R,R} +vg{x>3184:A,m<1418:R,x>2660:bld,A} +jt{x>2477:R,a>2635:zx,fsf} +hm{a>2487:A,a<2274:A,m<2628:R,R} +gdf{a>1833:A,m>2601:R,x>3693:A,A} +bn{s>2146:A,R} +mds{a<1669:kh,ks} +kjs{m<1076:bg,x<2959:sq,a>2348:jzk,nps} +tpd{m>3019:R,m<2929:zjz,dhm} +vj{a<3135:R,A} +in{m<1904:rmx,dv} +bg{x<2803:zk,A} +kq{s>335:R,x<1444:R,s<144:R,R} +dh{m<1504:A,x<1117:R,R} +glg{s>1491:A,a>2699:R,x<2115:R,R} +gq{m>582:A,s>2494:R,R} +czl{m>3218:lcc,a>1482:gdf,s>1070:R,jpv} +fb{x<798:A,m<1278:A,x<1320:A,R} +bgn{m<2676:A,x>1552:A,a<2102:A,R} +jkc{s>1316:lvr,A} +jff{s<1814:A,A} +pfp{a>1356:lk,s<2593:lb,vbm} +hzn{s>291:A,m<350:R,s>107:A,R} +nss{x>1361:R,m<275:R,A} +mt{a>1794:A,a<1619:A,R} +cbs{x>749:R,x>452:A,R} +zp{a>2382:R,m>2160:A,A} +cdj{m<1426:A,m<1470:R,R} +gkc{a>3431:A,m<2719:R,R} +rng{a<2253:A,s<1364:A,A} +cm{x<701:A,s<2077:R,R} +sl{s>218:A,a<1428:R,R} +lr{s<676:dnn,m<2639:R,tkc} +qrj{a>3647:A,R} +qfl{x<2572:pf,x<2780:R,a<3582:A,lzt} +kd{a>2021:R,x<3445:R,A} +hth{a<436:bj,a<537:A,a>618:rd,zch} +vtp{m>2029:fk,s<186:A,fv} +lk{x>1877:R,x<1197:hxn,s>2758:mg,qr} +fjh{s<1233:A,s>1369:A,A} +bl{x>3051:kdk,m>2606:cs,x>2593:qkb,dqk} +jxc{s<754:A,s<919:R,x>326:R,A} +sh{m<1271:ffg,x<2154:lpk,ml} +rvk{a>1716:jb,m>2310:mrd,x<929:bsr,mtv} +jz{s<2076:A,R} +gxf{m>119:R,R} +tm{s>2460:R,s<2108:A,R} +hs{a<1050:A,s>1331:A,A} +klm{m>334:A,a<3340:hg,mn} +vrf{x>831:qn,jss} +tk{x<714:R,m>536:A,A} +gcz{x>689:fgq,a>2814:R,a>2515:R,R} +vrc{a>617:hcc,bcq} +fv{x<323:A,a>731:R,m<1985:R,R} +qv{s<3495:nxn,ntn} +zqr{s>620:R,a>1126:bvl,a>521:klf,pht} +hcz{m>2716:R,a<1342:A,s<1707:A,R} +xn{s<2868:R,A} +ph{a<420:A,x<2533:R,a<671:R,A} +bp{a>1918:A,x<3035:rjr,m<1071:xzr,R} +zdf{a>958:A,pv} +hgp{a>1049:R,R} +mq{m>638:A,s<2293:A,a>616:pmb,ql} +cn{s<2663:A,R} +dhm{s>353:A,R} +jzk{s<568:R,x>3650:A,s>707:R,R} +cjk{x>2540:R,s>1858:A,m>3890:A,A} +crx{m>562:gq,x<1668:mf,x<2473:R,qgc} +bjh{s>952:A,R} +fxm{x<480:R,a<2492:A,x>663:dtc,cdt} +vfp{x<2978:R,s<2782:R,bx} +klf{s<297:R,A} +rm{a<641:vv,R} +flb{s<2029:R,A} +vnz{a>2624:A,R} +fth{m<3233:A,x>2427:A,a<1264:R,R} +qzc{s<2056:fd,x<2546:jmb,fp} +xzr{a<1702:A,x<3487:R,R} +spc{x<3466:A,R} +rvs{m<2531:R,s<732:R,a>1885:R,A} +bj{x<2674:R,x<3312:A,R} +ctq{x>2179:ktg,xcl} +ljf{a>2607:R,A} +sxk{a<2523:vlc,a<3269:nlv,pfc} +vkd{m<3011:R,A} +fpx{x<3400:R,m<513:A,m<550:R,A} +jvz{x<2305:R,R} +tp{s>785:clf,a>3143:fc,s>403:kjs,xbj} +bzr{x>2399:A,A} +ct{s<1142:R,m>1072:cxn,m<576:R,R} +dpz{x<2890:R,m<1145:R,m>1208:A,R} +tdk{s<953:R,s<1004:A,A} +vvf{a>308:R,R} +mdc{s<545:A,R} +zms{s<1338:vt,vqd} +sxq{s<539:bl,pb} +npq{a>1733:A,s<2028:R,A} +st{s>1119:kkn,a<1471:fth,a>1798:A,A} +qgx{s<2114:qg,x<2550:dx,kd} +tkc{s<834:A,s>935:R,s<888:A,R} +vn{a>368:A,x>2719:R,a<186:A,R} +hdj{m>1379:R,a<3199:A,R} +fdk{s>760:R,s<721:R,R} +jss{x<523:A,m>949:ljf,cf} +hfj{m<2440:R,A} +xmq{s>721:A,A} +glr{s<409:R,a>2481:vx,a<2006:rvs,R} +pn{s>103:A,x<1962:R,x<2041:R,R} +rbn{m>1175:A,x<1104:R,A} +kxh{s>260:A,R} +gj{x<583:R,R} +xhd{m>1531:A,x<2769:A,A} +ln{x>1465:R,m>3662:R,A} +kj{a>2600:R,a>2074:R,a<1875:A,R} +rds{s>3324:R,m>318:R,A} +dg{s<1209:R,x<1771:A,a<1172:R,R} +dj{m>2401:A,x<3015:A,R} +xcs{m>1181:A,qrj} +nr{x>2543:R,R} +jrf{s<1411:A,x>3427:A,a>2442:A,A} +mm{x<803:R,x>1048:A,R} +ts{m>185:nz,a<3026:pnb,zlb} +nz{a>2521:jzb,s>2272:fns,dqf} +jqg{x>791:tz,fxm} +rfz{m<1244:R,m>1510:A,m<1357:A,cdj} +mg{a<1429:A,A} +lld{a<2189:R,x<1847:R,x>3023:A,A} +fql{a>1962:A,A} +fc{s>306:xcs,s<188:bf,a>3705:kxh,knl} +qhm{a>3166:R,x<2392:R,s>2102:A,A} +bzs{s>3380:vll,s<3197:tsb,s>3273:rds,mld} +xxf{x>1829:lx,s>2658:ljc,sz} +mf{a<3800:R,A} +nk{a>2593:qc,hxg} +xsx{a<1715:A,a<1733:A,R} +sf{s<2353:fx,a<2799:cgr,a>3459:jj,jmg} +lg{a<481:R,m<3125:mdc,A} +lqs{s>2841:A,x>1238:A,a>2711:R,rg} +cdt{s>1120:R,s<974:R,m<793:R,A} +cgr{a>2377:jt,fql} +vv{m>2422:R,A} +pht{x>323:R,m<2739:R,s<391:A,A} +fd{s<1901:A,x>2345:R,R} +qnf{x>1052:A,A} +slf{x<2902:A,x<3031:hb,a>1612:xb,R} +rp{a<2688:qpg,s<561:zb,s>820:bjh,xmq} +xp{x<3009:A,s>3497:R,R} +sc{s<2609:vmn,x>1372:hth,gb} +xb{x<3182:R,m>2184:A,m<2037:R,R} +ntn{m>2269:A,A} +vpk{a<2369:R,m<252:A,x<2607:A,R} +vx{m<2559:R,R} +rjp{s<2679:A,a<2465:R,s<2825:A,A} +ms{m<1237:dg,a>1188:R,s>1186:hs,fsh} +vt{a>3078:A,m>3607:A,s<1211:R,R} +df{m<2520:A,A} +sft{a>1928:R,A} +hq{x>1359:R,m>1393:R,R} +dd{s<3456:jlj,A} +fph{s>1556:fj,s<564:ls,m<1556:hxz,zmf} +rs{m<1078:srt,fph} +ktg{s>3470:R,R} +zk{m<406:R,a>2584:A,R} +qjm{m>1597:A,s>2130:vfr,m>1500:cx,sxl} +zz{s>2430:A,A} +jl{m<1587:A,a<2096:R,a<2280:R,vqr} +vmt{m<3197:R,x<2588:R,x<2868:sm,R} +bk{x<2404:A,x>3166:R,A} +mdj{x<1270:A,A} +gk{x<2248:A,x<2842:A,A} +nt{m<2598:jc,x<407:A,s>1913:cm,R} +zkj{m<2762:qsf,s<609:R,mm} +fgq{x<850:A,a<3052:A,A} +vfr{a>3009:R,A} +xm{a>3477:A,m>406:R,x<960:A,R} +kkn{x<2769:A,a<1377:R,x<3030:A,R} +cf{x<659:R,x>729:A,A} +zmf{x>1721:zdf,rfj} +xpd{x<3509:R,s>2838:A,krk} +cq{m<808:A,s>2073:A,R} +xg{s>399:A,x>1421:A,sl} +lt{m<933:A,s<3372:R,s>3403:R,R} +rf{m<2272:A,a>1003:R,s>202:A,A} +bqd{a<3165:kj,rql} +lms{a>1748:A,s>2636:xsx,m<2315:R,df} +lkr{x<3666:R,R} +dvb{s>3461:qfh,s<3266:cdh,sh} +lvr{x<596:R,a>821:R,R} +xhv{s>2049:A,A} +xdl{s>1934:A,a<2067:R,s>1892:A,A} +dbl{s>2134:R,s<1998:R,R} +srt{s>1912:tn,vrc} +zq{x<2350:R,m<1616:R,A} +zpc{m<3078:nq,R} +ql{x<2222:R,a>217:A,m>243:R,A} +cs{m<3468:A,s<268:R,s>406:shg,nrp} +kp{a<604:R,A} +jzb{a<3429:A,A} +ls{x>2029:xhd,m>1549:hvh,tf} +qnr{m>1000:A,R} +dq{s<3056:hdj,s>3189:gk,m<1420:A,A} +tb{s>2981:R,m<3206:A,A} +glm{m>3351:vpg,tpd} +qsm{m<1972:A,m<2023:A,s<2691:A,R} +ft{x<2027:A,x>2763:A,R} +rn{x>1317:bhd,x<1173:tq,A} +dqk{x>2356:dbt,x>2136:zhq,a>1610:R,A} +nv{x>1361:bqd,a<2999:psb,m>357:fvj,klm} +jxf{m>2189:hfj,A} +js{a<2660:vmt,m>3052:kkl,qzc} +kpk{x<3286:A,x>3662:R,R} +qn{s>2152:R,s>2016:rbn,A} +kf{s>585:A,m>1213:R,A} +knl{x>2896:R,jr} +prh{a<1460:A,A} +jrq{a<426:R,a>638:R,R} +gl{x<3393:A,s<287:A,A} +fdp{x>267:A,s>393:R,A} +bsr{s>376:ncs,m<2142:vtp,zhs} +shg{s<469:A,x<2595:A,R} +ctz{m<2081:fdk,kxx} +nl{s<2520:A,m>2555:A,x<3105:R,R} +sxn{a>2415:gkc,R} +dbj{a>1076:R,a<489:R,A} +ljc{s<2911:vb,zpc} +fmg{x<1058:bn,a<2339:R,x>1297:A,A} +rfp{x<3517:dd,vm} +px{a<465:A,a>714:A,R} +dzg{s>3282:A,s<3184:R,s>3219:R,A} +lq{x>3134:A,R} +xv{s<919:A,a>320:R,s<1148:A,R} +dtq{x<2179:A,x>2391:ph,A} +lzt{s>1227:A,R} +rq{m<349:A,A} +rtk{s<2469:crq,nv} +dv{s>2329:pqs,x>1932:csf,zn} +vs{x<2598:ksm,qcr} +dpd{a<2738:qgx,m>1283:bbc,ffl} +rt{s>1987:R,m>2159:R,m>2063:A,R} +dtc{x<745:A,a>3398:A,m<1224:A,R} +rfj{s<990:kl,A} +rd{x<2353:R,a<648:R,x>3265:A,R} +xdm{x<1258:R,x>1548:A,R} +rmg{a>1998:R,s>2112:A,flb} +bv{s>774:R,x<3030:A,R} +fn{x>2408:pt,jh} +tt{m>2448:kbj,slf} +dz{a<2220:A,hhj} +ml{x>2990:fff,a<2565:R,kxp} +hd{m<570:lld,a<1904:lv,x<1590:A,bk} +hxg{x<3092:A,m>1196:R,s<1660:R,R} +cxn{x>3190:A,m<1403:A,s>1314:A,R} +jb{x>1245:jm,m<2402:krc,m>2698:zkj,glr} +pf{s<1266:A,m<2902:R,x>2251:R,R} +hj{x<1378:lvg,a<2521:jln,x>1817:rz,dts} +cpb{m>3169:dnk,m<2567:ckr,tcl} +dbk{m<56:R,x>700:A,a>3875:A,R} +pqs{s>3117:fq,a>1848:xxf,a>1154:dkn,cvl} +nlv{a<2823:A,a>3076:R,a>2987:R,R} +vtt{a>783:vdb,m<3188:R,s>2709:pc,A} +fx{a>2764:kbr,x>1635:rmg,m<589:sp,fmg} +nrp{a<1932:A,x>2604:A,a>3260:A,A} +sv{x>2615:R,s<2155:R,A} +cvv{m<2065:qsm,s<2757:R,R} +gvv{m<1550:R,kc} +hl{m>3176:A,x<3803:A,R} +rql{x>2295:A,s>2830:A,A} +jf{s<3352:kkh,m>311:R,m<107:fvl,R} +hxz{a>804:ms,zl} +ncs{x>559:A,m>2043:lc,a<640:A,jxc} +jlj{s>3247:A,A} +ffl{m<928:cq,a>3573:dpz,m>1062:A,qhm} +cfx{m<2449:fnf,pm} +bbc{m>1669:A,m<1442:jvz,x<2353:dmg,gfp} +fg{x<3812:R,m>2492:A,A} +jr{a>3444:R,a<3293:R,A} +dnk{m>3704:xdm,A} +dtr{m>2899:vfp,a>1679:lms,knr} +nsj{a>1009:st,m>2813:xpf,x<2635:dtq,px} +lnl{x>2417:A,A} +hnt{x<1231:npq,ln} +tf{a>536:dvj,fb} +qcr{x>3055:R,A} +kbj{m<2677:A,bxp} +jj{s>2662:mpz,m>609:sdq,a>3669:crx,lqv} +mtv{s<699:kp,s<859:ctz,tdk} +vzm{s>714:bv,s<612:A,x<3205:R,vxf} +zn{s>1050:vcd,m<2850:rvk,mrm} +cdk{x<2570:hnh,a>2692:R,s<2088:A,ps} +knr{s>2839:sjk,s>2584:A,s<2459:A,nl} + +{x=1464,m=163,a=691,s=469} +{x=61,m=72,a=436,s=2532} +{x=358,m=100,a=2631,s=347} +{x=266,m=439,a=1250,s=358} +{x=81,m=2110,a=30,s=86} +{x=1224,m=758,a=1133,s=881} +{x=1391,m=3763,a=16,s=2076} +{x=1149,m=1148,a=126,s=3270} +{x=214,m=590,a=492,s=818} +{x=1305,m=687,a=737,s=90} +{x=20,m=75,a=868,s=847} +{x=1588,m=99,a=2314,s=998} +{x=360,m=1002,a=33,s=164} +{x=68,m=1589,a=992,s=691} +{x=740,m=2150,a=691,s=668} +{x=2165,m=707,a=1189,s=161} +{x=158,m=53,a=416,s=1124} +{x=601,m=217,a=962,s=623} +{x=2,m=1314,a=1150,s=357} +{x=2931,m=1911,a=54,s=1046} +{x=1037,m=1,a=78,s=974} +{x=2460,m=689,a=1003,s=1253} +{x=1793,m=1250,a=331,s=306} +{x=243,m=247,a=156,s=146} +{x=1380,m=1600,a=387,s=1362} +{x=35,m=1900,a=38,s=411} +{x=349,m=118,a=2452,s=143} +{x=1314,m=2751,a=1835,s=1569} +{x=51,m=950,a=1436,s=376} +{x=347,m=2004,a=11,s=537} +{x=490,m=576,a=484,s=3066} +{x=1,m=891,a=3506,s=446} +{x=1994,m=519,a=644,s=1335} +{x=2230,m=1165,a=391,s=630} +{x=1606,m=853,a=1668,s=371} +{x=904,m=602,a=632,s=1969} +{x=583,m=794,a=2018,s=851} +{x=938,m=373,a=1253,s=104} +{x=704,m=514,a=617,s=525} +{x=366,m=1662,a=33,s=314} +{x=753,m=1002,a=285,s=170} +{x=959,m=2924,a=65,s=1249} +{x=222,m=701,a=8,s=610} +{x=887,m=350,a=209,s=3369} +{x=467,m=137,a=80,s=267} +{x=671,m=1325,a=928,s=2499} +{x=69,m=1915,a=539,s=277} +{x=119,m=2442,a=482,s=495} +{x=339,m=2398,a=1553,s=1128} +{x=1364,m=1330,a=1025,s=1678} +{x=527,m=325,a=341,s=602} +{x=309,m=1764,a=2066,s=1672} +{x=772,m=102,a=110,s=723} +{x=407,m=1522,a=2722,s=26} +{x=286,m=426,a=863,s=1849} +{x=483,m=1557,a=1569,s=74} +{x=487,m=3225,a=2582,s=2012} +{x=46,m=39,a=650,s=2371} +{x=98,m=1618,a=1354,s=1140} +{x=143,m=1488,a=2612,s=3212} +{x=1894,m=6,a=301,s=2723} +{x=880,m=50,a=1989,s=1331} +{x=899,m=308,a=3250,s=1097} +{x=6,m=235,a=868,s=246} +{x=128,m=1556,a=1238,s=746} +{x=561,m=1864,a=743,s=17} +{x=1170,m=525,a=473,s=2178} +{x=1927,m=581,a=164,s=1762} +{x=2467,m=1688,a=258,s=223} +{x=91,m=80,a=2047,s=1} +{x=592,m=261,a=374,s=2523} +{x=1624,m=507,a=3574,s=2063} +{x=1299,m=696,a=861,s=2958} +{x=521,m=188,a=1693,s=1079} +{x=184,m=570,a=1080,s=3064} +{x=895,m=188,a=714,s=93} +{x=488,m=123,a=4,s=1884} +{x=174,m=231,a=499,s=2306} +{x=1309,m=1190,a=629,s=1364} +{x=3901,m=1901,a=3133,s=806} +{x=104,m=3125,a=420,s=80} +{x=1108,m=13,a=118,s=1537} +{x=79,m=228,a=1099,s=1009} +{x=151,m=1805,a=439,s=158} +{x=1140,m=26,a=358,s=254} +{x=33,m=859,a=1798,s=2119} +{x=1351,m=875,a=154,s=1526} +{x=193,m=1105,a=181,s=273} +{x=1669,m=697,a=3436,s=2059} +{x=2207,m=1038,a=3441,s=17} +{x=1619,m=451,a=126,s=613} +{x=179,m=925,a=61,s=1001} +{x=377,m=489,a=516,s=2503} +{x=1234,m=254,a=1687,s=1737} +{x=157,m=243,a=807,s=2647} +{x=2085,m=2178,a=1890,s=2279} +{x=2543,m=41,a=1601,s=958} +{x=491,m=651,a=1024,s=147} +{x=1728,m=2320,a=1243,s=2661} +{x=3255,m=52,a=300,s=12} +{x=454,m=17,a=328,s=3} +{x=25,m=2552,a=1744,s=2031} +{x=914,m=1956,a=2626,s=537} +{x=70,m=1644,a=1296,s=3639} +{x=183,m=105,a=1468,s=729} +{x=1054,m=817,a=54,s=797} +{x=303,m=26,a=54,s=2919} +{x=426,m=425,a=2235,s=290} +{x=3366,m=1016,a=249,s=1868} +{x=553,m=1259,a=1205,s=1739} +{x=381,m=92,a=1879,s=1959} +{x=340,m=2787,a=697,s=1705} +{x=967,m=174,a=119,s=125} +{x=2039,m=128,a=1808,s=187} +{x=610,m=3225,a=159,s=133} +{x=655,m=584,a=1571,s=1545} +{x=453,m=2305,a=2208,s=1144} +{x=264,m=2748,a=54,s=3012} +{x=1780,m=1205,a=85,s=731} +{x=994,m=538,a=2258,s=122} +{x=721,m=293,a=116,s=1491} +{x=92,m=871,a=938,s=1245} +{x=824,m=66,a=217,s=1124} +{x=1386,m=2328,a=22,s=1487} +{x=134,m=208,a=3476,s=103} +{x=2079,m=956,a=696,s=1512} +{x=330,m=685,a=640,s=1277} +{x=828,m=178,a=149,s=861} +{x=1803,m=1792,a=3530,s=1056} +{x=490,m=146,a=606,s=1823} +{x=1095,m=12,a=1532,s=2254} +{x=956,m=549,a=1656,s=2066} +{x=589,m=129,a=377,s=1081} +{x=703,m=423,a=1326,s=692} +{x=1962,m=554,a=3730,s=403} +{x=805,m=13,a=2957,s=435} +{x=1014,m=1169,a=877,s=1628} +{x=231,m=1783,a=3029,s=450} +{x=2631,m=1113,a=2281,s=598} +{x=1253,m=689,a=1380,s=269} +{x=1218,m=257,a=693,s=1838} +{x=2592,m=157,a=2692,s=2610} +{x=182,m=1834,a=2526,s=2412} +{x=7,m=2186,a=1092,s=2759} +{x=378,m=2142,a=223,s=2671} +{x=4,m=1224,a=1,s=1266} +{x=362,m=665,a=1354,s=1927} +{x=938,m=1440,a=779,s=451} +{x=653,m=861,a=782,s=69} +{x=1917,m=1353,a=2782,s=493} +{x=768,m=226,a=774,s=2560} +{x=2358,m=129,a=916,s=2} +{x=1437,m=57,a=2611,s=535} +{x=1620,m=713,a=399,s=975} +{x=925,m=1213,a=196,s=40} +{x=2587,m=1109,a=403,s=614} +{x=2329,m=1563,a=2339,s=221} +{x=1135,m=1141,a=2005,s=660} +{x=336,m=831,a=244,s=561} +{x=1860,m=527,a=1251,s=4} +{x=108,m=3112,a=467,s=1376} +{x=1024,m=1249,a=291,s=289} +{x=1016,m=2544,a=380,s=681} +{x=1029,m=2456,a=140,s=1858} +{x=1896,m=86,a=814,s=2106} +{x=948,m=2199,a=1919,s=1537} +{x=1073,m=304,a=770,s=824} +{x=1495,m=735,a=355,s=208} +{x=775,m=118,a=105,s=132} +{x=94,m=686,a=2362,s=1493} +{x=663,m=202,a=89,s=1471} +{x=415,m=285,a=639,s=594} +{x=357,m=1340,a=558,s=686} +{x=375,m=1342,a=875,s=323} +{x=951,m=600,a=172,s=1109} +{x=607,m=161,a=1132,s=327} +{x=1158,m=117,a=360,s=1463} +{x=813,m=2117,a=497,s=1136} +{x=37,m=1790,a=644,s=174} +{x=1744,m=133,a=1954,s=24} +{x=1701,m=466,a=939,s=132} +{x=2230,m=1484,a=287,s=46} +{x=883,m=3196,a=1629,s=523} +{x=40,m=2274,a=2969,s=1136} +{x=2391,m=25,a=1371,s=598} +{x=476,m=1117,a=678,s=1095} +{x=515,m=1488,a=265,s=1929} +{x=2765,m=325,a=834,s=826} +{x=717,m=5,a=1380,s=4} +{x=45,m=5,a=526,s=558} +{x=756,m=3112,a=1,s=721} +{x=388,m=760,a=635,s=2132} +{x=2335,m=987,a=4,s=1253} +{x=201,m=1422,a=2646,s=166} +{x=585,m=684,a=146,s=522} +{x=2358,m=998,a=1386,s=1620} +{x=844,m=379,a=2917,s=903} +{x=2701,m=3418,a=1938,s=1538} +{x=1603,m=357,a=2232,s=2683} +{x=3046,m=3073,a=194,s=169} \ No newline at end of file diff --git a/Advent2023/Data/Day19_Test.txt b/Advent2023/Data/Day19_Test.txt new file mode 100644 index 0000000..3dfc810 --- /dev/null +++ b/Advent2023/Data/Day19_Test.txt @@ -0,0 +1,17 @@ +px{a<2006:qkq,m>2090:A,rfg} +pv{a>1716:R,A} +lnx{m>1548:A,A} +rfg{s<537:gd,x>2440:R,A} +qs{s>3448:A,lnx} +qkq{x<1416:A,crn} +crn{x>2662:A,R} +in{s<1351:px,qqz} +qqz{s>2770:qs,m<1801:hdj,R} +gd{a>3333:R,R} +hdj{m>838:A,pv} + +{x=787,m=2655,a=1222,s=2876} +{x=1679,m=44,a=2067,s=496} +{x=2036,m=264,a=79,s=2244} +{x=2461,m=1339,a=466,s=291} +{x=2127,m=1623,a=2188,s=1013} \ No newline at end of file diff --git a/Advent2023/Day18.cs b/Advent2023/Day18.cs index 5d1297d..0522063 100644 --- a/Advent2023/Day18.cs +++ b/Advent2023/Day18.cs @@ -146,7 +146,7 @@ static bool IsL(Partition part) return vertices.Count == 3; } - // Cap of open parts of the shape so that we still have a continuous line + // Cap off open parts of the shape so that we still have a continuous line void CreateVerticalSeals(Partition part, IEnumerable<(long x, long y)> exits, bool ascending) { (exits.Count() % 2).Should().Be(0); @@ -495,20 +495,18 @@ public void Part2(string filename, long expectedAnswer) public void Part2_Shoelace(string filename, long expectedAnswer) { var verts = LoadVertices(filename); - long s1 = 0; - long s2 = 0; - long length = 0; + long area = 0; for (int i = 0; i < verts.Count - 1; i++) { - s1 += verts[i].x * verts[i + 1].y; - s2 += verts[i].y * verts[i + 1].x; - length += long.Abs((verts[i].x - verts[i+1].x) + (verts[i].y - verts[i+1].y)); + area += (verts[i].x * verts[i + 1].y) - (verts[i].y * verts[i + 1].x); + + // We need to factor in the volume of the line itself as well + // https://www.reddit.com/r/adventofcode/comments/18l2nk2/2023_day_18_easiest_way_to_solve_both_parts/kdv9bfk/ + area += long.Abs(verts[i].x - verts[i+1].x + verts[i].y - verts[i+1].y); } - // We need to factor in the volume of the line itself as well - // https://www.reddit.com/r/adventofcode/comments/18l2nk2/2023_day_18_easiest_way_to_solve_both_parts/kdv9bfk/ - var area = ((s1 - s2 + length) / 2) + 1; + area = (area / 2) + 1; area.Should().Be(expectedAnswer); } diff --git a/Advent2023/Day19.cs b/Advent2023/Day19.cs new file mode 100644 index 0000000..7767942 --- /dev/null +++ b/Advent2023/Day19.cs @@ -0,0 +1,297 @@ +using FluentAssertions; +using System; +using System.Collections.Generic; +using Utils; +using Xunit; + +namespace Advent2023 +{ + public class Day19 + { + record Widget(long x, long m, long a, long s); + + enum Result + { + Continue, + Accept, + Reject, + }; + + delegate Result Process(Widget w); + + Func ParseCondition(string condition) + { + var match = condition.Match(@"^(.)(.)(\d+)$"); + long value = long.Parse(match.Groups[3].Value); + if (match.Groups[2].Value == "<") + { + return match.Groups[1].Value switch + { + "x" => w => w.x < value, + "m" => w => w.m < value, + "a" => w => w.a < value, + "s" => w => w.s < value, + _ => throw new Exception() + }; + } + + return match.Groups[1].Value switch + { + "x" => w => w.x > value, + "m" => w => w.m > value, + "a" => w => w.a > value, + "s" => w => w.s > value, + _ => throw new Exception() + }; + } + + Process ParseProcess(Func reader) + { + Dictionary functions = []; + var line = reader(); + while (!string.IsNullOrEmpty(line)) + { + var match = line.Match(@"^(\w+){(.+)}$"); + var name = match.Groups[1].Value; + var instructions = match.Groups[2].Value.Split(','); + var steps = new Process[instructions.Length]; + + Result Accept(Widget w) => Result.Accept; + Result Reject(Widget w) => Result.Reject; + + for (int i = 0; i< instructions.Length; i++) + { + var parts = instructions[i].Split(':'); + string target = parts.Length == 2 ? parts[1] : parts[0]; + + Process next = target switch + { + "A" => Accept, + "R" => Reject, + _ => w => functions[target](w) + }; + + if (parts.Length == 2) + { + var condition = ParseCondition(parts[0]); + steps[i] = w => + { + if (condition(w)) + return next(w); + return Result.Continue; + }; + } + else + { + steps[i] = next; + } + } + + functions[name] = w => + { + foreach (var step in steps) + { + var result = step(w); + switch (step(w)) + { + case Result.Accept: + case Result.Reject: + return result; + } + } + throw new Exception(); + }; + + line = reader(); + } + + return functions["in"]; + } + + List ParseWidgets(Func reader) + { + List widgets = []; + + var line = reader(); + while (line != null) + { + var match = line.Match(@"^{x=(\d+),m=(\d+),a=(\d+),s=(\d+)}$"); + widgets.Add(new( + long.Parse(match.Groups[1].Value), + long.Parse(match.Groups[2].Value), + long.Parse(match.Groups[3].Value), + long.Parse(match.Groups[4].Value) + )); + line = reader(); + } + + return widgets; + } + + long Sum(Widget widget) + { + return widget.x + widget.m + widget.a + widget.s; + } + + [Theory] + [InlineData("Data/Day19_Test.txt", 19114)] + [InlineData("Data/Day19.txt", 492702)] + public void Part1(string filename, long expectedAnswer) + { + var reader = FileIterator.CreateLineReader(filename); + var process = ParseProcess(reader); + var widgets = ParseWidgets(reader); + + long total = 0; + + foreach (var widget in widgets) + { + var result = process(widget); + if (result == Result.Accept) + { + total += Sum(widget); + } + } + + total.Should().Be(expectedAnswer); + } + + + //---------------------------------------------------------------------------------------// + // Part 2 + //---------------------------------------------------------------------------------------// + + record Range(int min, int max); + + record Check(char field, int value, char op, string target); + + Dictionary ForkLower(Dictionary widget, char field, int value) + { + Dictionary newWidget = new(widget); + Range lower = new(widget[field].min, value); + Range upper = new(value, widget[field].max); + + newWidget[field] = lower; + widget[field] = upper; + + return newWidget; + } + + long ValidCount(Dictionary widget) + { + long total = 1; + foreach (var range in widget.Values) + { + total *= range.max - range.min; + } + return total; + } + + Dictionary> ParseChecks(Func reader) + { + Dictionary> functions = []; + + var line = reader(); + while (!string.IsNullOrEmpty(line)) + { + var match = line.Match(@"^(\w+){(.+)}$"); + var name = match.Groups[1].Value; + var steps = match.Groups[2].Value.Split(','); + List checks = []; + + foreach (var step in steps) + { + var parts = step.Split(":"); + if (parts.Length == 1) + { + checks.Add(new('x', int.MaxValue, '<', parts[0])); + } + else + { + match = parts[0].Match(@"^(.)(.)(\d+)$"); + var field = match.Groups[1].Value[0]; + var op = match.Groups[2].Value[0]; + var value = int.Parse(match.Groups[3].Value); + checks.Add(new(field, value, op, parts[1])); + } + } + + functions[name] = checks; + line = reader(); + } + + return functions; + } + + long Solve(Dictionary> functions, string function, Dictionary widget) + { + if (function == "A") + { + return ValidCount(widget); + } + else if (function == "R") + { + return 0; + } + + long total = 0; + var checks = functions[function]; + foreach (var check in checks) + { + var range = widget[check.field]; + if (check.op == '<') + { + if (check.value <= range.min) + { + continue; + } + + if (range.max <= check.value) + { + return total + Solve(functions, check.target, widget); + } + + var lower = ForkLower(widget, check.field, check.value); + total += Solve(functions, check.target, lower); + } + else // (check.op == '>') + { + if (range.max < check.value + 1) + { + continue; + } + + if (range.min > check.value) + { + return total + Solve(functions, check.target, widget); + } + + var lower = ForkLower(widget, check.field, check.value + 1); + total += Solve(functions, check.target, widget); + widget = lower; + } + } + + return total; + } + + [Theory] + [InlineData("Data/Day19_Test.txt", 167409079868000)] + [InlineData("Data/Day19.txt", 138616621185978)] + public void Part2(string filename, long expectedAnswer) + { + var reader = FileIterator.CreateLineReader(filename); + var functions = ParseChecks(reader); + + Dictionary widget = new() { + ['x'] = new(1, 4001), + ['m'] = new(1, 4001), + ['a'] = new(1, 4001), + ['s'] = new(1, 4001) + }; + + var total = Solve(functions, "in", widget); + total.Should().Be(expectedAnswer); + } + } +}