-
-
Save gibson042/a21967812a21d9d22051f9593b1e4925 to your computer and use it in GitHub Desktop.
Advent of Code 2021 - Day 19 Part 2 - Console Golfing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(await(await fetch("https://adventofcode.com/2021/day/19/input")).text(Q=[])).replace(r=/.*,.*|(\d+)/g,(d,s)=>(s?Q:q).push(s?q=[]:eval(`[${d}]`))) | |
T=[],[...'+3+6!-!+5-7-6!+!-8-5!+8+6+8+5!-8-6-!-7-7+-7!-!-1--7!+!+8+!-7!+8+-7-8-!-7!-8-2-!+!+3+6!+!-5-7-6!-!-!-7-7+-7!+!0--8'.replace(r,t=>'+!-!!!+!!!'.slice(t))][F="flatMap"]((s,i)=>((T[i/9|0]??=[])[i%9/3|0]??=[])[i%3]=s+1|0) | |
M=(t,m)=>t.map(o=>m?o[D]((s,p,i)=>s+m[i]*p,0):t[F](p=>m+1?N=(n=o.l[D]((s,o,i)=>s+A(o-p.l[i]),0))>N?n:N:p[D="reduce"]((s,p,i)=>s+A(o[i]-p)**2,0))) | |
for(A=Math.abs,S=JSON.stringify,R=Q[N=0],R.l=[0,0,0];Q.find(q=>(t=(H=q.l?0:M(R)[F]((e,x)=>M(q)[F]((d,B)=>d[D]((c,a)=>c+e.includes(a),0)>11?[[x,B]]:[]))).length>11&&T.find(t=>H.find(([r,u])=>(V[r=S(u=R[r][F]((p,i)=>p-M(t,q[u])[i]))]|=0,++V[r]>11?U=q.l=u:0),V={})))&&q[F](P=>S(P=M(t,P)[F]((p,i)=>U[i]+p))in R[F](S)||R.push(P))););M(Q,0) | |
N |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment