This commit is contained in:
Joshua Seigler 2021-12-12 16:53:44 -05:00
parent 24a01bde52
commit 5143f5c770

1
2021/day12.js Normal file
View file

@ -0,0 +1 @@
s='start',e='end',M={},b=(f,t)=>{if(f!=e&&t!=s)M[f]=[...(M[f]||[]),t]};$`pre`.innerText.split`\n`.map(l=>{[f,t]=l.split`-`;b(f,t);b(t,f)});C=(h,d)=>(L=h[h.length-1],L==e?1:(L>']'&&h.slice(0,-1).includes(L)&&d++)?0:M[L].reduce((a,t)=>a+C([...h,t],d),0));[1,0].map(x=>C([s],x))