diff options
author | Oscar Najera <hi@oscarnajera.com> | 2023-12-20 07:49:53 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2023-12-20 07:49:53 +0100 |
commit | 889849613fd6afb6b2d7e6f64a513be3c72fcdf0 (patch) | |
tree | 0e23744d6de0555045c72e17992813308d750308 | |
parent | 2f95eb9292719cdcb597937f2afd8e2b67b14e20 (diff) | |
download | scratch-889849613fd6afb6b2d7e6f64a513be3c72fcdf0.tar.gz scratch-889849613fd6afb6b2d7e6f64a513be3c72fcdf0.tar.bz2 scratch-889849613fd6afb6b2d7e6f64a513be3c72fcdf0.zip |
[AoC2023] day19 part 1 lisp
-rw-r--r-- | AoC2023/day19/eg-in | 17 | ||||
-rw-r--r-- | AoC2023/day19/input | 794 | ||||
-rw-r--r-- | AoC2023/day19/solver.lisp | 60 |
3 files changed, 871 insertions, 0 deletions
diff --git a/AoC2023/day19/eg-in b/AoC2023/day19/eg-in new file mode 100644 index 0000000..e5b5d64 --- /dev/null +++ b/AoC2023/day19/eg-in @@ -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} diff --git a/AoC2023/day19/input b/AoC2023/day19/input new file mode 100644 index 0000000..7e61fb0 --- /dev/null +++ b/AoC2023/day19/input @@ -0,0 +1,794 @@ +rr{s>898:A,s>537:A,a>2567:R,A} +gmr{x<1782:A,x<1819:R,R} +dln{m<1743:R,R} +kd{x>1248:xsx,m<797:cxm,ppz} +lsv{m<2789:R,A} +ld{a>2638:A,x<2418:tsb,sds} +bb{x<2091:gb,s>2804:lxr,vz} +rjc{s<2734:R,x<709:R,R} +ng{x<3090:A,a<3366:R,a>3456:R,R} +fdh{a<2472:jbt,chz} +pg{x<3179:A,x>3508:R,s<2653:R,A} +ckl{x<1338:R,s>1155:R,R} +tt{m<3331:R,x<2654:R,a<2193:R,A} +vk{x>1759:hzr,xgr} +pgn{s>3747:A,R} +ksl{a>1008:dq,s>1178:vc,a<669:A,A} +frt{s<2175:R,x<3670:R,R} +hk{x>767:jn,lvr} +dnq{s<1989:A,A} +rcp{a>1871:A,x<879:A,s>3196:A,A} +vdc{s>1410:A,x<2648:R,R} +hp{x>3237:R,R} +sps{s<2626:A,A} +fsz{a>1966:R,R} +dtd{x<3224:A,x<3493:njp,R} +nzm{s>1996:R,s>1738:R,R} +shm{m<3138:A,m>3515:A,A} +rbl{s>2903:A,A} +rqr{a<1658:cz,a>2538:hr,cr} +mfd{m<2895:bkh,m>3041:R,x>605:R,kpt} +cxm{x<733:fqb,m<305:lh,A} +mtj{a>682:A,m<514:R,R} +nqp{x<1742:xmh,m<2426:qg,a<1664:zn,mdq} +qbc{s>1746:R,a>3471:A,A} +gcb{a>3873:R,x>901:A,s>2526:R,A} +ddt{a<1612:xxx,x>874:pzr,kxp} +jln{x>2909:btr,s<3265:R,x>2454:A,fxb} +fv{m<3341:crk,nt} +fcc{m<1595:R,a>1673:R,R} +vdl{a<917:A,x>3085:A,A} +xh{x>3911:A,m>1584:A,a<3658:R,R} +fb{x<2218:R,a<3097:csq,x<2966:A,R} +rg{s<228:A,A} +vv{s>2743:R,m<2300:A,gtc} +kt{s<3205:A,x<2474:R,R} +jd{x>2598:mmz,a>3196:R,a<2880:A,qc} +sm{m<3026:R,s<2220:A,R} +vpk{m<2927:pnv,s<2002:gbg,fqr} +prz{x<2475:A,x>2503:A,A} +nn{x<2989:nqs,m>908:A,x<3617:hp,A} +nc{m>2293:A,x>2254:A,R} +rz{m<1776:A,R} +hg{a<3470:A,A} +cmk{s<1993:A,R} +fph{m<3353:qkz,s>2130:lnd,s<1710:dt,nfk} +hx{m>3288:R,x<2240:R,a<3464:A,R} +kjk{m<1183:sf,s<3408:nlb,sgz} +lzg{x<2160:fcv,x<2444:kc,a<2312:cvn,qs} +czj{x<2114:A,x>2307:R,A} +sx{s>3037:mgt,qgq} +bpz{x>1117:hkk,s<2508:bvv,cgs} +lgh{s>2692:ql,s>1935:R,m>346:R,jpx} +rfl{a>1490:R,x>3507:R,R} +vh{x>2183:bnd,a<2596:R,a>2867:A,A} +rb{x<2254:gtn,bdh} +ndf{x<2115:lxm,hkf} +sv{s<3585:A,m>1776:xrs,a>2949:nl,A} +lg{a>1486:R,A} +lv{m>893:A,x<1036:R,m>524:A,R} +jbt{m>2850:R,m>2575:bpt,ghx} +xvd{s<2329:klf,s>2728:A,s>2480:A,qj} +gg{a>3498:R,A} +ggg{x>1001:A,a<2616:R,s<659:A,R} +sgz{a>3756:A,R} +zn{a<950:bh,pnj} +ps{a>1703:zs,a>670:kl,a<445:pt,lk} +jhb{s<568:vsn,s<1048:lz,a<2079:vfv,zkv} +bd{s<628:R,x>3025:A,R} +dt{m>3610:A,A} +mx{m<3109:R,A} +ql{a>995:R,a>973:R,A} +prb{m>2030:rsc,m>1898:A,s<2334:dnq,A} +pxv{s<870:php,m<1064:lx,zf} +qhf{m<1946:A,R} +fq{a<3277:R,a>3518:R,s<1199:A,R} +mvc{x<2140:R,x>2193:A,a>1442:R,R} +qn{m<3781:mmd,jgc} +kfz{x<2837:A,m>321:R,R} +kgb{s<696:A,R} +lq{m>541:R,x>1193:A,x>903:A,R} +jj{s<479:mjb,jzr} +zt{s>3076:jln,qz} +csq{m>578:R,R} +jm{s<3473:R,A} +qkm{x<3127:R,x>3236:R,A} +sf{s<3412:kcg,szg} +zcd{a<1421:qzl,sv} +gpk{x>2366:R,R} +sj{x>3520:A,m<2544:R,R} +pvd{x>1715:A,a<2497:A,x<1089:R,R} +pr{s<1859:R,a>3529:A,a<3397:R,R} +djb{m<1114:sh,qrb} +czq{s>516:R,x<2218:R,s<218:A,A} +vb{s<1894:R,a<184:A,R} +vqj{a<2270:vht,R} +kvq{a>3727:A,a>3597:hqb,m>1854:A,R} +kpt{a>688:A,m>2946:R,s<2011:A,A} +tsb{a>2200:A,m>3082:A,m>2940:R,R} +vsl{a>1614:A,a>768:R,a<375:A,R} +lxm{m>2209:A,x<1948:R,kpl} +zbj{a>787:A,a<502:R,R} +pt{m<2952:nd,s<361:qk,rf} +vqc{a>3208:gh,a<2817:fxj,hph} +lx{a<1928:kx,nn} +fp{x<2488:A,a>2594:A,a>2565:sd,lqr} +pl{s<2435:R,x>3489:R,a>2005:A,R} +km{s>2297:gg,s>1995:kr,jmj} +mjb{x<3145:R,x<3583:R,R} +gbf{m>2386:hsv,a<2812:sgd,s>3107:fkm,xrg} +hkf{x<2196:A,m>2222:nc,tfj} +hps{m<591:rh,x>2182:kjk,tl} +xt{s>3069:tml,x>1527:djf,kb} +tts{m<1713:fcc,a>1665:rz,rjc} +kcg{a<3603:A,R} +xms{a<2083:R,s>1109:A,A} +qj{m<1531:A,a>3029:A,R} +hqf{s>3712:R,A} +zdp{a<631:A,m<2934:R,R} +phs{s>2172:R,m<2954:A,s>1925:R,A} +sds{x<2514:A,x<2551:A,A} +lm{x>2416:A,s<2513:R,a<1459:A,R} +bkh{s<2508:R,s>2810:R,A} +tlz{a<935:pb,A} +mh{x<1362:R,s>1153:R,x>2831:A,R} +bvq{m<2140:srz,fjj} +lxf{s<1017:A,x>2469:R,A} +hm{m<1965:R,s>573:A,s>193:R,A} +lvr{x>427:R,A} +rtv{x>3401:R,m<2251:R,s>2426:R,A} +hqb{s>2435:R,x>720:R,s<1864:A,R} +qd{a>2748:ts,s>920:xk,jj} +dvr{x>3050:R,A} +vht{m<689:A,s<2425:R,s<2806:A,A} +zm{x>3152:zhj,fqq} +sh{m>993:R,A} +mk{m<2712:xb,x>2142:gpk,m<2743:zr,psh} +chs{x<3929:R,s>1942:R,m<2796:ffh,mx} +khd{x<3748:R,A} +pmr{x>2509:A,A} +zcq{s<2618:R,A} +rs{a<595:R,a>852:A,m>3564:A,A} +dxt{m>1128:A,lzj} +lng{a<2870:df,A} +kpl{s<2493:R,a<1131:R,A} +fgg{m>2455:R,m>2339:fz,x<921:A,R} +sqz{m<2787:R,x>3528:R,R} +qb{a>1416:A,x<3393:A,A} +bnd{m>2536:A,a<2513:A,A} +tjk{x<2066:R,a<369:A,a>606:R,A} +mmd{x<2980:dm,a<3007:zvt,ls} +cvp{x<3229:R,A} +zb{a>2688:A,x>2968:A,m>700:A,R} +nlh{s>1869:A,m>2299:R,A} +kx{s<1117:brj,s>1248:zz,x<3062:fnb,lsf} +xq{a<1263:A,x>1846:A,x<720:R,A} +mmz{a<3150:A,s>2097:A,a>3567:R,R} +jxh{a<1249:R,R} +fqb{a>2654:A,A} +sd{s<1805:R,x<3073:A,a<2580:A,R} +fmt{m<2299:R,s>3647:A,A} +jn{a>3654:R,a<3493:A,x<1507:A,A} +th{m<2025:hm,a>1062:R,R} +lz{s>782:bf,R} +pvt{m<1601:A,x<3907:A,A} +mg{x<723:R,m<1201:A,s<634:A,A} +lh{s>3524:A,x<967:A,a<2778:A,R} +cjm{a<3316:R,x<2600:xxp,m<2257:A,R} +szg{x<2812:R,x>3229:R,A} +lsf{m<962:A,x>3551:R,R} +cn{x<1332:R,a<3320:R,x<1904:R,A} +nnr{x<2403:R,s<1216:A,m>1777:A,A} +ppz{s>3407:jv,R} +lb{s>3415:A,s<3183:A,R} +pnj{s>2768:fv,a>1283:fph,qps} +fcv{x<1943:pv,a<2408:A,hhv} +bf{s>924:R,s>855:R,A} +dmz{a<661:R,A} +lk{a<528:R,s>385:R,a<587:A,zdp} +pj{a<3750:R,s<626:A,A} +xm{m>1846:A,a<1390:A,R} +tfj{x<2270:A,R} +np{m>2347:R,x<2638:A,s<3079:A,A} +pv{s>2196:A,m>2764:A,s>1919:R,A} +cz{x>1399:qtt,s>865:ksl,frk} +fl{x>2916:R,m<1121:R,R} +kmf{m>317:R,A} +ss{x<1134:mfd,zjv} +klf{s>1901:R,R} +ck{m>591:cx,mb} +nzj{a<1820:csd,a<2110:pl,A} +tml{s<3444:kbk,x>2333:xl,pgn} +pd{a<2025:R,x<2085:R,x>2165:R,A} +bdh{a<1985:dp,a>3257:dln,dh} +kcn{m>3720:nm,s>407:gl,R} +ds{s>804:kj,kcn} +dkk{x>3424:mpl,x<2914:A,R} +njp{a<1942:R,s<1774:A,m<1577:A,A} +qq{a<435:shm,x<3562:R,m<3020:jf,A} +tl{a<3669:rdm,qf} +lvp{m<1360:R,A} +grg{s<3251:A,m>3391:rq,s>3321:R,R} +qtd{m<2016:cjk,bv} +nhp{x>3803:fj,a>2417:R,x>3717:A,A} +bk{x>2355:A,A} +zj{a>3455:A,s>2113:A,A} +kxz{x>2356:qcj,x>2284:R,a<395:vb,R} +hc{a<960:czq,s>822:R,m<2057:R,dks} +fkm{x>935:lmt,ksg} +rn{a<1457:R,x>2594:A,R} +hkk{m>3533:A,R} +qk{x<1619:A,A} +xl{x<3394:mvg,s<3791:gbp,db} +srq{s>1922:ttc,s<1675:pm,s>1833:R,R} +lmt{a>3368:lth,px} +fzq{m>516:szn,x>2314:dlf,m>240:gx,R} +jgc{m>3858:gt,s<2009:fxg,zm} +sxj{s<1686:R,R} +bv{x>746:A,R} +gdf{x<2202:A,m>2735:R,x<2226:R,R} +xn{s<2594:A,pg} +lns{m>209:A,x>1172:A,x>653:A,R} +xpm{m>970:R,R} +dlf{a<3819:A,s<2152:R,x>3103:R,A} +xlm{s>3506:R,s<3114:A,x<237:R,dd} +ltl{m<3266:R,x>2923:R,R} +fxg{x<3039:R,R} +kvd{a<2015:A,a<2203:A,A} +xk{a>2472:A,A} +dr{m>3536:A,R} +lxr{a>314:R,s<3374:zvm,hqf} +js{m<2209:brg,mcs} +ml{m>1632:R,s<2988:hvt,a>2498:R,gm} +cp{s>719:fq,A} +mgt{m<3413:A,a>532:R,a<286:R,R} +vcf{m<727:R,x<3292:R,s<2732:R,A} +btr{x>3446:R,x>3238:R,a>3185:R,A} +hn{x>1913:tjk,m<3321:A,R} +zl{s<2584:R,vdl} +dp{a>968:lm,m>1728:xnm,R} +vmx{x<3249:R,x>3273:A,m>2220:A,rvk} +mzz{a>2648:cp,x<1344:th,x<2953:hc,xj} +vr{a<1115:A,R} +vf{m<826:R,gcb} +qzc{x<2839:A,s>3582:A,x>3469:R,A} +nx{s<2192:A,x>499:R,s>2202:R,A} +fjj{m<2326:A,m<2504:A,a>1056:A,dqz} +mpl{m<1525:A,s<2419:A,a<1827:R,A} +lcl{a<705:A,x<1817:A,A} +jpx{s<1668:R,s<1827:R,R} +xsx{x>1669:R,A} +rjq{s>3727:R,m>3423:pmr,a>568:R,A} +ghx{m>2501:A,s>2929:R,s>2720:A,R} +gb{a>279:R,s<3000:R,A} +jt{a<878:kq,m<2314:jxh,lg} +fqk{s<1110:lxf,s>1180:vsl,R} +gxx{a>2598:R,x<3064:A,m<3929:A,A} +kcp{m>1060:ppk,s<404:R,R} +psh{x<1950:A,x<2028:R,A} +rm{x<341:jt,x<501:vv,s<2942:lgf,fmt} +xch{s<2107:A,R} +tmv{a>2923:xg,s<2964:gs,x<2196:kd,hnn} +kxp{x<293:A,R} +vsn{s>326:A,x>2098:qrr,R} +qms{a>1941:A,m<2303:A,A} +zh{s<2793:R,R} +fsd{m>1626:pld,zq} +bsx{x<2013:A,x<2171:A,A} +bm{a<3244:A,x<346:A,s<3829:R,R} +ct{s>3112:qdp,a>3271:A,R} +jp{a<1671:qjv,m<664:smj,R} +ddd{a>620:A,A} +bcc{x<1209:A,x>1887:pd,m>954:kvd,nr} +ppk{a>1976:A,s<567:R,R} +hq{a<3395:ltl,a<3598:phj,R} +nl{s>3806:R,a>3467:A,a<3193:R,R} +hr{s>608:qtz,rg} +ngm{m>464:ck,a<2048:gn,x<1680:vqc,qd} +sfc{a<2871:R,x<3171:R,A} +drh{a<932:rgr,a>1062:zcq,lgh} +xb{m<2690:A,m>2699:A,s<2160:R,A} +zq{s<2147:R,m>1598:A,R} +hf{s>2241:R,R} +pld{a>3224:A,x>3679:A,s<2225:R,R} +rp{x>2208:gr,m<2385:A,x<2025:R,A} +tp{m>642:cb,a<496:bb,drh} +dk{m<793:ngm,x<2235:rqr,pxv} +kq{x>142:R,a>320:R,m>2119:R,R} +brj{x<3156:A,s<1001:A,x<3516:R,A} +hzr{m>800:cj,m<350:bnp,dz} +dvq{a<2817:rfk,s<3640:hsr,s>3834:hq,nbh} +zvt{a<2194:qr,m>3582:A,R} +hbc{m>3311:A,s<3819:R,A} +xrg{a>3374:kvq,qtd} +ldt{a<452:A,a>935:A,R} +tv{a>2686:R,R} +fnb{x<2659:R,m<950:A,A} +bvv{s>2099:rs,x<646:A,dmz} +ksg{s<3593:R,s<3769:A,s<3882:bm,A} +xc{a>3887:gfs,a>3825:A,ghr} +rsd{x<3011:R,x<3633:A,A} +nz{x<2602:A,R} +skv{s>2643:sk,m<2211:jd,m>2315:rp,cjm} +gq{x<213:A,a<3282:R,x<293:R,R} +kc{s>2101:R,x<2259:gdf,A} +rfk{a>2407:lfs,a>2066:A,x>2992:tnc,R} +zdm{x<2998:R,A} +kj{m>3825:A,s<1051:A,A} +mb{x<1966:A,a>1499:lt,m<543:nmd,vt} +qzl{a<793:jqf,m>1686:cpg,R} +nfk{s>1960:cvp,R} +rlh{m>2779:hpm,mk} +cvn{s>1938:dpv,x>2495:R,A} +lqr{m<633:A,m<963:R,A} +gtc{s<2207:R,A} +pb{a>441:R,A} +gbp{a>1802:R,m>560:A,A} +brg{m<2150:rn,a<1739:ddd,nz} +lsb{a>2810:R,a<2751:lr,s>1951:R,nvv} +qcj{a>398:R,s>1884:A,A} +jhn{s>624:A,a>2215:R,A} +mhd{s>2442:lv,m<919:lq,m<1293:R,nmf} +xrs{a<2872:A,s>3844:R,a<3570:R,R} +xxx{x<724:dr,m>3415:A,m<3044:R,A} +tb{s>569:A,s>199:A,s<116:R,R} +zhj{s>2372:A,x>3453:A,x>3285:A,A} +gl{x<2441:R,R} +gfs{s>1715:A,s<1599:A,A} +zkv{m<1595:R,a>3150:nnr,s<1240:mh,pvd} +chn{x>3256:A,x<3078:R,A} +cpz{x>2062:mvc,x<1856:gmr,s>3599:rgb,czs} +ghr{a<3760:R,A} +gn{x>1698:dhv,kgb} +kr{x<1124:A,m>1069:A,s<2187:A,R} +sgd{a<2278:mgb,m<1822:ml,prb} +dh{m>1731:A,R} +dkg{a>2779:A,a<2711:zb,R} +ls{x<3343:qkm,s<2028:A,jq} +mm{a<846:R,a<1339:xgt,a<1472:xm,rl} +lzr{s>2689:A,s<2630:A,x<2720:R,R} +gh{a>3561:pj,vtl} +nt{x>2734:R,a>1190:A,s>3248:A,A} +vs{x<447:R,R} +in{s<1496:qfr,m<1482:tj,nqp} +zs{m<3096:A,a<2616:tt,hx} +cdf{a<3463:R,s<2048:A,m>1382:R,R} +dd{a<3213:R,x>308:R,m<2995:R,A} +pks{a>1889:A,A} +qjv{m<982:R,R} +srz{s>2452:jm,s>1986:zp,x<1249:sxj,A} +xgr{m>642:km,xxn} +bh{s>2773:gsg,vsg} +xj{x<3493:chn,R} +tj{a>2506:tm,sl} +jf{s<3734:A,a<661:A,s<3836:R,R} +khx{m>2843:tmp,m<2675:mz,a>3041:rlh,lzg} +sk{x<2346:R,x<2697:A,x>2851:A,fjq} +vpq{a<663:A,s>2293:R,a>950:A,A} +xgt{a<1048:A,A} +tnc{a>1862:A,s<3634:R,m<3035:R,R} +ln{m>2932:bzj,s>1151:A,R} +lff{a<1901:A,x<2187:R,R} +nbh{s<3743:mdb,s<3790:ffc,hbc} +rhg{a>1320:R,A} +vz{a<183:lvq,cmk} +fz{x>790:R,m<2400:R,R} +vt{a>598:A,x>3231:R,a>341:R,R} +qps{m>3221:hpr,s<2321:srq,xn} +mcs{a<1515:np,s>2811:A,fsz} +dks{m>2130:R,a<1599:A,R} +hsv{x>985:ct,x>359:dn,s<2526:lng,xlm} +lvq{m<239:A,A} +dv{a<410:A,s>2028:R,R} +fg{x<1959:A,A} +jv{m<1064:A,a<2658:R,x<805:A,A} +kl{m>3040:sfh,a<1130:R,a<1421:xq,A} +mgb{s>2339:tnz,m>1888:R,x<962:A,jg} +cjk{s>2328:A,s<1781:A,R} +fxb{s>3309:A,R} +php{s<442:dxt,bd} +qg{m>2070:hb,x>2549:cns,rb} +dm{a>2594:zj,x<2401:R,A} +pxr{m<1112:qnh,vpq} +hsr{x<2752:R,nh} +tqz{s>2208:vf,s<1834:xc,njr} +lth{x<1440:R,A} +nmd{a<519:R,A} +gz{x>3410:R,x<3234:R,m<1288:R,xms} +qcz{a<129:R,m<3340:R,a<262:A,R} +rq{s<3311:R,A} +tgj{s>3014:rlb,a>1111:ddt,m<3242:ss,bpz} +vbg{x>3262:R,m>3573:R,m>3497:A,R} +mvg{a>1759:R,a>1407:R,A} +qrb{m>1334:A,A} +fqj{s<2511:A,s<2628:A,x<2454:A,R} +jmj{s>1807:R,R} +frk{s<428:A,mg} +pnv{a>3010:R,vqn} +vd{x<1353:tqz,vhs} +cgs{m<3529:R,a<683:R,A} +dqz{m<2565:A,R} +bnp{s<2087:R,R} +lrb{m<1290:vdc,rd} +fqq{m>3817:R,A} +vhs{m>830:djb,fzq} +jz{x<3495:rmt,x>3782:bz,m<1563:xvd,fsd} +zsr{x>2541:A,a>2559:R,s<3324:A,A} +qz{m>3837:vcq,s>2754:R,A} +krk{s>3368:dvq,m<3290:fdh,m<3627:tlc,zt} +kb{x>523:mhd,gnz} +phj{m>3335:R,x>2520:A,A} +pzr{a<1772:hf,R} +gm{x<594:A,A} +zp{x>1210:A,m>1969:R,x<1048:A,R} +ts{x>2800:tb,A} +tm{a<3317:tmv,s>2777:hps,a<3704:vk,vd} +vqt{a>1817:ln,lcl} +cns{s>2940:zcd,m>1705:ttp,a>2419:jz,vm} +cx{x>1442:dg,A} +blp{m>2932:nzm,A} +lnd{x<2860:fqj,s>2378:vbg,rfl} +cjv{m>1230:R,m<1160:R,x>1829:R,A} +vcq{s>2890:A,a<3193:R,R} +lt{m>548:A,A} +nq{m<1869:ltb,x>754:bvq,rm} +dpv{s>2266:R,s>2088:A,R} +pq{s>1896:A,a>508:A,R} +dn{s<2714:R,A} +rmt{a<3310:R,m<1579:qvx,a>3685:R,R} +fj{x<3905:A,R} +hb{x>3135:ncf,a>2657:skv,x>2312:js,ndf} +zjv{x<1393:dv,phs} +zrc{m>2599:kh,mf} +hmd{x>2391:R,x<2249:A,a<359:qcz,R} +qf{m<1072:R,R} +ltb{a>1271:tts,sps} +vfv{s<1311:rhg,s<1382:R,R} +vm{a<1357:sc,s<2086:dtd,m>1566:nzj,dkk} +nlb{s>3125:lvp,rbl} +qkz{a>1431:lsv,a<1354:drt,m<2748:A,R} +fx{m>278:R,R} +fxt{m<158:A,s>2504:A,s>2278:A,A} +ttc{m>2738:A,x>2531:R,R} +xg{s>2648:cpj,fb} +cpg{s>3571:A,A} +vbf{x<2621:R,A} +smj{x>2619:R,s<2380:A,m<229:R,A} +rd{x>2635:R,R} +ft{a>2590:R,x<1805:A,R} +nvv{m<769:R,a<2775:A,x>1901:R,R} +zvm{m<425:A,s<3125:A,A} +jzr{a>2495:R,m<230:A,m>358:R,R} +qrr{x>3109:A,A} +pm{x>2979:R,R} +hpm{s<2127:qbc,m>2821:A,A} +tbj{x<2306:R,vcf} +klg{x<2349:fgg,m>2394:rr,mq} +tmh{x>1022:R,a<3888:R,R} +vqn{s<2159:R,R} +hhv{x<2021:R,s<1880:R,A} +sl{a<1190:tp,xt} +tnz{x<637:A,m<1928:R,A} +gtk{x<3823:qnc,a<3156:chs,blp} +qr{s>2187:R,R} +lr{x>2636:R,a>2729:R,s<2032:R,R} +gs{s>2370:tbj,a>2691:lsb,s<2037:fp,ft} +cpj{m>531:mr,x>1562:A,fx} +rl{m>1941:A,x<3272:A,A} +cb{x>1857:ldt,s>2780:jxb,pxr} +ffh{a<2544:A,s<1696:R,A} +mq{m>2314:tc,R} +bz{a<3452:pvt,xh} +djf{a>1857:vqj,a>1478:jp,s>2415:qll,mpj} +xql{s>3276:R,x>2910:R,R} +qnh{x<1118:A,m>843:A,A} +xnm{m<1895:A,s>2744:R,a<429:R,R} +db{s<3888:A,m>601:R,A} +tlc{s<3095:cs,m<3502:grg,tsj} +gtn{s<2926:fg,m<1735:lmg,cpz} +rdm{s<3565:hg,a<3476:R,A} +jxb{x>920:hvd,m<1098:R,R} +qvx{m<1542:R,s<2014:R,A} +rsc{s<2569:A,x>1132:R,m<2161:A,R} +hpr{s<2269:A,x>2982:A,m>3565:A,vr} +rk{s>2288:R,A} +gsg{s<3382:sx,x>3097:qq,rjq} +lgf{s>2430:A,nlh} +drt{x>2910:A,R} +qnc{x>3593:qcm,m>2860:R,m>2715:sqz,sj} +dg{s<957:R,A} +szn{m<655:R,s>2167:R,A} +mdq{s>2571:krk,m>3381:qn,x<2597:khx,fk} +gr{a>3183:R,R} +czs{s<3213:A,A} +nh{m>3197:A,A} +xs{a>2602:A,s>3647:A,x>3027:R,zsr} +rlb{m>3367:lb,tlz} +mr{x<1877:R,s<3159:R,A} +qtz{m>1148:A,x>796:cn,x<350:gq,R} +jqf{s<3537:R,m<1818:R,m<1976:A,A} +jq{a>3381:R,A} +bpt{x>2985:A,R} +xmh{a>1944:gbf,m<2610:nq,tgj} +cs{x<3029:R,x<3443:R,x>3665:zh,dnz} +hvd{a>606:R,m<949:A,m>1293:A,R} +njr{x>841:tmh,s<2080:vs,s>2160:nx,tmd} +hvt{s<2301:R,A} +qgq{s>2891:R,R} +zr{m>2727:R,a>3625:A,a<3304:R,A} +ncf{x>3563:nhp,x>3308:xhk,vmx} +hnn{a<2656:xs,dkg} +qc{x<2060:A,s>2092:R,R} +rf{m>3287:A,A} +vsg{x>2667:nsp,x<2143:hn,s>2296:hmd,kxz} +bzh{a>2579:A,R} +tmd{x<388:A,s<2111:R,R} +zf{x>2922:gz,s<1243:fqk,lrb} +dq{x<595:A,R} +fxj{a>2401:ggg,jhn} +qll{s<2846:glt,s>2969:bk,R} +bx{m>3107:A,m<2664:R,s<2211:A,A} +qtt{m>1113:cjv,A} +mpj{a>1377:R,m<514:kmf,R} +mz{a>3073:czj,a>2229:vh,lff} +sfh{x<1574:A,s<319:A,R} +fcz{m<1841:A,a<1372:R,m<1889:R,R} +ttp{a>1724:qhf,s<2454:md,s>2659:mm,zl} +vc{a<458:R,m>1073:R,m>916:A,R} +gnz{x>273:xpm,pks} +nqs{m<968:R,a<2977:R,A} +fk{x>3474:gtk,vpk} +vtl{s<935:A,x>669:R,m<289:R,A} +lmg{s<3290:bsx,R} +px{m<2033:A,A} +ll{x>918:R,A} +chz{s>2904:A,lzr} +dnz{x>3587:R,x<3525:R,R} +dhv{m>237:kfz,m<129:R,A} +qcm{x<3703:A,m<3001:A,A} +zhv{a>1975:R,m>3165:R,x<3102:A,R} +ffc{a<3463:A,A} +nd{x<1799:A,a<282:A,R} +kh{m>3492:ds,s>745:vqt,ps} +nsp{x<3541:dvr,a>347:bx,x>3714:xch,sm} +mpf{s>1573:R,m<3914:R,R} +jg{x>1236:A,R} +cr{s<913:kcp,m>1073:ckl,bcc} +tc{a>2626:A,a>1730:A,a<807:R,R} +qs{x<2526:prz,a<2677:A,A} +nr{s>1250:R,m>861:A,R} +nmf{m>1404:R,R} +dz{m<506:vbf,x<3002:R,m<699:A,A} +rh{x>2099:qzc,hk} +hph{a>3015:R,ll} +bzj{m<3249:R,m>3352:A,s>1192:R,R} +sc{m>1588:rk,x<3464:zbj,m<1543:khd,frt} +csd{a>1549:A,s>2395:R,s>2241:R,A} +gbg{m<3100:A,a<3189:A,a>3566:zdm,ng} +xxp{s>2181:A,A} +df{x>187:R,m>3063:R,R} +kbk{x<2193:rcp,m>629:fl,x>2839:R,kt} +nm{a<2075:A,x>2139:R,a>2877:R,A} +mf{m<1887:jhb,m<2219:mzz,klg} +gx{x>1676:A,R} +fjq{s>3372:R,R} +qdp{a>2663:A,R} +xxn{m>393:R,s<2156:pr,fxt} +fqr{a>2845:R,a>2145:A,zhv} +gt{s>1855:gxx,s<1616:mpf,sfc} +crk{m>2882:xql,x>2847:qb,s>3421:R,R} +zz{m>927:A,A} +tsj{a>2927:R,a<2375:A,bzh} +xhk{x<3458:rtv,s>2967:qms,m<2272:A,A} +rgb{m>1904:A,m<1840:A,a>1965:R,A} +cj{a>3542:A,m<1223:rsd,x<2929:R,cdf} +glt{s>2671:R,R} +md{m>1924:A,a<858:pq,x<3172:fcz,R} +lfs{x<2524:A,x>3069:A,R} +lzj{x<2843:R,A} +qfr{m<1406:dk,zrc} +tmp{x<2199:tv,ld} +mdb{x>3031:A,x<2213:R,x<2547:A,A} +rgr{m>335:mtj,x<1850:lns,R} +rvk{x<3262:A,x>3266:R,R} + +{x=4,m=211,a=430,s=167} +{x=469,m=1450,a=3037,s=1084} +{x=90,m=929,a=457,s=661} +{x=1411,m=2566,a=1085,s=162} +{x=770,m=1427,a=132,s=385} +{x=213,m=1476,a=443,s=1024} +{x=1845,m=1234,a=2052,s=528} +{x=261,m=330,a=2087,s=3049} +{x=2520,m=545,a=2023,s=1094} +{x=687,m=1369,a=716,s=194} +{x=1260,m=534,a=959,s=1228} +{x=1681,m=824,a=31,s=536} +{x=1469,m=527,a=732,s=28} +{x=1385,m=318,a=812,s=849} +{x=43,m=2439,a=943,s=1751} +{x=1281,m=992,a=1310,s=181} +{x=1442,m=772,a=529,s=835} +{x=2938,m=1243,a=129,s=149} +{x=135,m=1141,a=2930,s=233} +{x=1183,m=503,a=17,s=794} +{x=1365,m=674,a=1118,s=466} +{x=1797,m=3174,a=94,s=478} +{x=673,m=39,a=1324,s=2} +{x=179,m=525,a=1441,s=240} +{x=160,m=131,a=569,s=116} +{x=6,m=2905,a=2176,s=692} +{x=535,m=136,a=976,s=659} +{x=48,m=452,a=456,s=111} +{x=91,m=752,a=83,s=462} +{x=498,m=2390,a=823,s=1728} +{x=87,m=463,a=1934,s=290} +{x=1089,m=340,a=767,s=325} +{x=2231,m=618,a=188,s=2526} +{x=949,m=778,a=796,s=3} +{x=221,m=834,a=978,s=2262} +{x=47,m=1045,a=770,s=2395} +{x=1588,m=1497,a=2445,s=2042} +{x=328,m=3727,a=965,s=101} +{x=983,m=21,a=2960,s=1218} +{x=1257,m=568,a=116,s=931} +{x=115,m=935,a=672,s=8} +{x=1232,m=683,a=524,s=1018} +{x=2056,m=55,a=151,s=47} +{x=2274,m=3,a=1274,s=1394} +{x=820,m=257,a=2131,s=52} +{x=77,m=786,a=1227,s=909} +{x=1257,m=1794,a=1188,s=164} +{x=41,m=148,a=2604,s=2708} +{x=959,m=342,a=79,s=867} +{x=469,m=1603,a=256,s=1002} +{x=1327,m=237,a=1347,s=2324} +{x=78,m=3089,a=421,s=3047} +{x=906,m=198,a=1236,s=975} +{x=1058,m=722,a=2347,s=1361} +{x=915,m=1370,a=1440,s=1965} +{x=5,m=314,a=394,s=108} +{x=3398,m=1630,a=482,s=120} +{x=1554,m=93,a=1116,s=2315} +{x=1690,m=39,a=2643,s=1211} +{x=939,m=2613,a=3295,s=186} +{x=840,m=2014,a=3302,s=459} +{x=43,m=232,a=964,s=87} +{x=667,m=497,a=1160,s=495} +{x=2706,m=2042,a=2244,s=483} +{x=975,m=449,a=930,s=1339} +{x=1151,m=1834,a=527,s=1691} +{x=250,m=134,a=49,s=516} +{x=1483,m=1059,a=218,s=1478} +{x=226,m=66,a=61,s=558} +{x=308,m=174,a=40,s=234} +{x=405,m=133,a=112,s=788} +{x=98,m=1228,a=566,s=141} +{x=114,m=107,a=3002,s=156} +{x=108,m=246,a=635,s=107} +{x=999,m=2323,a=1085,s=742} +{x=2503,m=652,a=431,s=349} +{x=2282,m=189,a=980,s=109} +{x=694,m=647,a=100,s=93} +{x=2799,m=2992,a=2464,s=1168} +{x=124,m=2107,a=3773,s=275} +{x=1483,m=317,a=101,s=549} +{x=1336,m=1202,a=391,s=1762} +{x=432,m=1018,a=607,s=2628} +{x=107,m=1890,a=1284,s=136} +{x=1058,m=2632,a=715,s=573} +{x=44,m=1094,a=1008,s=320} +{x=895,m=505,a=72,s=82} +{x=2687,m=1993,a=1872,s=1213} +{x=2894,m=477,a=981,s=2140} +{x=3112,m=998,a=161,s=790} +{x=701,m=173,a=228,s=692} +{x=181,m=1880,a=1149,s=2655} +{x=1738,m=25,a=1689,s=664} +{x=326,m=639,a=898,s=2477} +{x=768,m=190,a=798,s=75} +{x=1039,m=910,a=220,s=447} +{x=3467,m=116,a=2314,s=1479} +{x=1658,m=41,a=1785,s=2015} +{x=954,m=975,a=1251,s=2291} +{x=1800,m=1086,a=89,s=448} +{x=3594,m=230,a=448,s=192} +{x=451,m=1579,a=112,s=585} +{x=2087,m=600,a=1780,s=3617} +{x=1922,m=3067,a=2375,s=273} +{x=3346,m=2213,a=1478,s=294} +{x=285,m=22,a=2823,s=1645} +{x=393,m=471,a=180,s=259} +{x=1531,m=1343,a=962,s=766} +{x=224,m=442,a=246,s=26} +{x=104,m=2282,a=249,s=703} +{x=235,m=3230,a=958,s=1576} +{x=618,m=535,a=1359,s=116} +{x=887,m=1569,a=697,s=634} +{x=2988,m=56,a=165,s=1516} +{x=431,m=485,a=3671,s=3} +{x=320,m=835,a=1176,s=821} +{x=303,m=1070,a=908,s=2023} +{x=1821,m=805,a=32,s=826} +{x=1026,m=208,a=495,s=31} +{x=68,m=1034,a=776,s=1527} +{x=2130,m=2428,a=295,s=2667} +{x=2172,m=2671,a=1253,s=1171} +{x=260,m=268,a=287,s=2112} +{x=670,m=1720,a=2780,s=1252} +{x=1342,m=1103,a=29,s=1807} +{x=26,m=633,a=1111,s=1011} +{x=286,m=281,a=1693,s=19} +{x=334,m=339,a=1664,s=695} +{x=264,m=73,a=671,s=494} +{x=628,m=2637,a=193,s=11} +{x=581,m=1288,a=13,s=1968} +{x=2739,m=423,a=276,s=235} +{x=58,m=853,a=2449,s=403} +{x=1372,m=1674,a=530,s=348} +{x=1203,m=612,a=2013,s=927} +{x=2071,m=38,a=873,s=807} +{x=3006,m=484,a=1048,s=1820} +{x=2648,m=1457,a=119,s=1726} +{x=1452,m=269,a=158,s=1565} +{x=1251,m=2330,a=153,s=1006} +{x=1092,m=2264,a=122,s=2840} +{x=422,m=562,a=555,s=897} +{x=280,m=937,a=1348,s=1518} +{x=313,m=1531,a=1959,s=633} +{x=1288,m=1598,a=880,s=2325} +{x=1895,m=104,a=3321,s=501} +{x=1924,m=4,a=452,s=2542} +{x=2907,m=1684,a=358,s=212} +{x=1620,m=593,a=795,s=1268} +{x=1041,m=1848,a=643,s=894} +{x=436,m=13,a=2,s=35} +{x=2010,m=88,a=444,s=711} +{x=161,m=412,a=99,s=262} +{x=757,m=1129,a=914,s=3258} +{x=2688,m=76,a=1494,s=1868} +{x=96,m=976,a=1875,s=747} +{x=1358,m=489,a=1478,s=472} +{x=981,m=1761,a=828,s=36} +{x=2085,m=1122,a=1635,s=80} +{x=2,m=1466,a=73,s=366} +{x=1798,m=748,a=251,s=33} +{x=370,m=3060,a=452,s=69} +{x=608,m=1287,a=583,s=484} +{x=1077,m=1238,a=541,s=2277} +{x=1465,m=726,a=235,s=416} +{x=429,m=995,a=1610,s=1557} +{x=152,m=2480,a=309,s=355} +{x=1418,m=357,a=1360,s=18} +{x=569,m=425,a=1511,s=385} +{x=1116,m=2349,a=1539,s=2429} +{x=185,m=1187,a=2544,s=357} +{x=1134,m=231,a=209,s=650} +{x=1007,m=88,a=195,s=1443} +{x=38,m=179,a=1868,s=994} +{x=264,m=616,a=397,s=922} +{x=153,m=2015,a=3754,s=1093} +{x=1284,m=201,a=324,s=1085} +{x=21,m=2025,a=13,s=1510} +{x=268,m=760,a=1173,s=1210} +{x=1563,m=2290,a=260,s=2754} +{x=65,m=3398,a=1110,s=320} +{x=399,m=379,a=3098,s=1723} +{x=1235,m=3170,a=554,s=393} +{x=2272,m=16,a=772,s=977} +{x=150,m=3141,a=3700,s=3335} +{x=456,m=669,a=829,s=961} +{x=74,m=2087,a=292,s=1245} +{x=232,m=18,a=572,s=1622} +{x=153,m=2306,a=1841,s=712} +{x=935,m=43,a=822,s=128} +{x=959,m=40,a=414,s=312} +{x=788,m=1129,a=1275,s=1622} +{x=1264,m=1939,a=68,s=9} +{x=2201,m=1598,a=133,s=937} +{x=479,m=890,a=2502,s=667} +{x=318,m=893,a=405,s=17} +{x=1066,m=644,a=519,s=67} +{x=399,m=1118,a=1010,s=394} +{x=236,m=219,a=41,s=90} +{x=789,m=1619,a=202,s=1014} diff --git a/AoC2023/day19/solver.lisp b/AoC2023/day19/solver.lisp new file mode 100644 index 0000000..9c2f0a0 --- /dev/null +++ b/AoC2023/day19/solver.lisp @@ -0,0 +1,60 @@ +;;6:51 +;;7:49 +;; +(ql:quickload '(fiveam cl-ppcre arrows)) + +(defstruct part + x m a s) + +(defun part-sum (part) + (with-slots (x m a s) part + (+ x m a s))) + +(defun solve (filename) + (let ((workflows (make-hash-table)) + parts) + (loop for line in (uiop:read-file-lines filename) + do + (cond + ((string-equal line "")) + ((eq #\{ (aref line 0)) + (cl-ppcre:register-groups-bind ((#'parse-integer x m a s)) + ("{x=\(\\d+\),m=\(\\d+\),a=\(\\d+\),s=\(\\d+\)}" line) + (push (make-part :x x :m m :a a :s s) parts))) + ((multiple-value-bind (name rule) (parse-rule line) + (setf (gethash name workflows) rule))))) + (reduce #'+ parts :key (alexandria:curry #'test-part workflows)))) + +(defun parse-tests (line-rule) + (loop for test in (cl-ppcre:split "," line-rule) + collect + (cl-ppcre:register-groups-bind ((#'read-from-string prop op val target)) + ("\(\\w\)\(<|>\)\(\\d+\):\(\\w+\)" test) + (list op prop val target)))) + +(fiveam:test parts + (fiveam:is (equal + '((< S 537 GD) (> X 2440 R)) + (parse-tests "s<537:gd,x>2440:R" )))) + +(fiveam:test solutions + (fiveam:is (= 19114 (solve "eg-in"))) + (fiveam:is (= 446517 (solve "input")))) + +(defun parse-rule (line) + (cl-ppcre:register-groups-bind ((#'read-from-string name) (#'parse-tests tests) (#'read-from-string default)) + ("\(\\w+\){\(.*\),\(\\w+\)}" line) + (values name + (lambda (part) + (or (loop for (op prop val target) in tests + when (funcall op (slot-value part prop) val) + do (return target)) + default))))) + +(defun test-part (workflows part &optional (start 'in)) + (let ((out (funcall (gethash start workflows) part))) + (cond ((eq 'A out) + (part-sum part)) + ((eq 'R out) 0) + ((test-part workflows part out))))) +(fiveam:run!) |