From 5143f5c77009721f76d69e8fdd673c16b79caed8 Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Sun, 12 Dec 2021 16:53:44 -0500 Subject: [PATCH] day 12 --- 2021/day12.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 2021/day12.js diff --git a/2021/day12.js b/2021/day12.js new file mode 100644 index 0000000..48ef7d2 --- /dev/null +++ b/2021/day12.js @@ -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)) \ No newline at end of file