Skip to content

Instantly share code, notes, and snippets.

@emplv
Created December 4, 2019 08:21
Show Gist options
  • Select an option

  • Save emplv/0c4551112a3443cb23f13617962306f8 to your computer and use it in GitHub Desktop.

Select an option

Save emplv/0c4551112a3443cb23f13617962306f8 to your computer and use it in GitHub Desktop.
AoC 2019 - day 4
const INPUT = '000000-000000';
const [ from, to ] = INPUT.split`-`;
// Part 1
for(x=0,i=from;i<to;)
(a=[...''+i++]).every((c,j)=>!j||+c>=+a[j-1])
&&a.some((c,j)=>c==a[j-1])
&&x++,x
// Part 2
for(x=0,i=236491;i<713786;)
(a=[...''+i++]).every((c,j)=>!j||+c>=+a[j-1])
&&a.some((c,j)=>c==a[j-1]&&a.filter(y=>y==c).length==2)
&&x++,x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment