mirror of
https://github.com/seigler/advent-of-code-browser-console
synced 2025-07-26 00:06:10 +00:00
2021 solutions so far
This commit is contained in:
parent
ccc3cdba3a
commit
5986c9bd69
2 changed files with 2 additions and 0 deletions
1
2021/day01.js
Normal file
1
2021/day01.js
Normal file
|
@ -0,0 +1 @@
|
|||
d=$('body').innerText.trim().split`\n`;t=(d,n)=>d.reduce((a,x,i)=>a+(+x>d[i-n]),0);[t(d,1),t(d,3)]
|
1
2021/day02.js
Normal file
1
2021/day02.js
Normal file
|
@ -0,0 +1 @@
|
|||
d=$('body').innerText.trim().split`\n`.map(l=>l.split` `);[(j=d.reduce((a,[c,v])=>({f:a=>v=>(a.h+=v,a),d:a=>v=>(a.d+=v,a),u:a=>v=>(a.d-=v,a)}[c[0]](a)(+v)),{h:0,d:0}),j.h*j.d),(k=d.reduce((a,[c,v])=>({f:a=>v=>(a.h+=v,a.d+=a.a*v,a),d:a=>v=>(a.a+=v,a),u:a=>v=>(a.a-=v,a)}[c[0]](a)(+v)),{h:0,d:0,a:0}),k.h*k.d)]
|
Loading…
Add table
Add a link
Reference in a new issue