Skip to content

Instantly share code, notes, and snippets.

@emplv
Last active December 6, 2019 07:39
Show Gist options
  • Select an option

  • Save emplv/468bc5632284b61642ec78a4ff8b6ddc to your computer and use it in GitHub Desktop.

Select an option

Save emplv/468bc5632284b61642ec78a4ff8b6ddc to your computer and use it in GitHub Desktop.
AoC 2019 - day 5
const INPUT = `
COPY & PASTE HERE
`.trim``.split`,`;
// part 1
(z=y=>([q,w,e,r]=t.slice(y),99-(u=q%100))?(t[[,r,r,w][u]]=[,(i=(b=q/100|0)&1?w:t[w])-+-(o=b&8?e:t[e]),i*o,x][u],z(y+2**2**(u<3))):+i)(0,x=1,t=[...INPUT]);
// part 2 (also works for part1)
(z=y=>([q,w,e,r]=t.slice(y),99-(u=q%100))?(t[[,r,r,w][u%6]]=[,(i=(b=q/100|0)&1?w:t[w])-+-(o=b&8?e:t[e]),i*o,x,,,,i<o,i==o][u],z(y+=u%7<3?4:u<5?2:u<6^!+i?+o-y:3)):i)(0,x=5,t=[...INPUT]);
//
x=5,t=[...fetchSync('http://ix.io/23CO').trim().split(',')];
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment