Last active
December 8, 2019 21:31
-
-
Save emplv/ed61b5e0246a410701e2017db0f1f6d6 to your computer and use it in GitHub Desktop.
Advent of Code - day 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const INPUT = ``.trim(); | |
| // part 1 | |
| INPUT.match(/.{150}/g).map(X=>[X.replace(/1|2/g,x=>(x<2?O++:T++,''),O=T=0),O*T]).sort()[0][1] | |
| // part 2 | |
| // INPUT.match(/.{150}/g).reduce((t,b)=>[...t].map((x,i)=>x<2?x:b[i]).join``).match(/.{25}/g) | |
| // [...INPUT].map((x,i,a)=>a[j=i%150]<2?a[j]:a[j]=x).join``.slice(-150).match(/.{25}/g) | |
| [...INPUT].reduce((r,x,i)=>(r[j=i%150]=r[j]<2?r[j]:x,r),[]).join``.match(/.{25}/g) | |
| // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment