From fbcef85736c2899679ea2b670bdca6f92adb97c0 Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Sun, 12 Dec 2021 20:49:01 -0500 Subject: [PATCH] shorter --- 2021/day12.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2021/day12.js b/2021/day12.js index b400268..ff1b518 100644 --- a/2021/day12.js +++ b/2021/day12.js @@ -1 +1 @@ -s='start',e='end',M={},b=(f,t)=>f!=e&&t!=s?M[f]=[...(M[f]||[]),t]:0;$('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)) \ No newline at end of file +s='start',e='end',M={},b=(f,t)=>f!=e&&t!=s?M[f]=[...M[f]||[],t]:0;$('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))