Skip to content

Instantly share code, notes, and snippets.

@Picoseconds
Last active December 5, 2021 01:24
Show Gist options
  • Save Picoseconds/12068266d217f0a16bb435d134c11a59 to your computer and use it in GitHub Desktop.
Save Picoseconds/12068266d217f0a16bb435d134c11a59 to your computer and use it in GitHub Desktop.
Very cool Advent of Code 2021 solutions
alert(
`123
124
124
126
...`.split`
`.reduce(([z,e],c)=>[+c,e+(c>z)],[,0])[1]
);
alert(
`123
124
124
126
...`.split`
`.reduce(([z,e],c,i,a)=>[+c,e+(a[i+2]>z)],[,0])[1]
);
alert(
`123
124
124
126
...`
.split`
`.reduce(([e,c,i],l)=>[e+("f"==l[0])*l.slice(-1),c+("f"==l[0])*l.slice(-1)*i,i+{u:-1,d:1,f:0}[l[0]]*l.slice(-1)],[0,0,0]).slice(0,-1).reduce((e,c)=>e*c);
);
alert(
`123
124
124
126
...`
.split`
`.reduce((c,M)=>c.map((e,i)=>e+2*(+M[i]-.5)),Array(12).fill(0)).reduce(([e,c],d,i)=>[e|(Math.sign(d)+2)/2-.5<<11-i,c|(2-Math.sign(d))/2-.5<<11-i],[0,0]).reduce((e,c)=>e*c)
);

advent of code 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment