mirror of
https://github.com/seigler/advent-of-code-browser-console
synced 2025-07-25 07:46:09 +00:00
day 22
This commit is contained in:
parent
b75c87af88
commit
fc6c4c750f
1 changed files with 1 additions and 0 deletions
1
2021/day22.js
Normal file
1
2021/day22.js
Normal file
|
@ -0,0 +1 @@
|
|||
Q=$("pre").innerText.trim().split`\n`.map(a=>([o,c]=a.split` `,{o,c:c.split`,`.map(b=>b.match(/-?\d+/g).map(a=>+a))})),V=a=>a.reduce((d,[e,a])=>d*(a+1-e),1),I=([d,a],[b,e])=>(j=d>b?d:b,k=a<e?a:e,j>k?null:[j,k]),O=(a,d)=>d.reduce((e,f,b)=>(z=a.map((b,a)=>I(b,f.c[a])),z.includes(null)?e:e+V(z)-O(z,d.slice(b+1))),0),[Q.slice(0,20),Q].map(a=>a.reduce((b,d,e)=>b+("on"==d.o&&V(d.c)-O(d.c,a.slice(e+1))),0))
|
Loading…
Add table
Add a link
Reference in a new issue