Created
December 4, 2019 08:21
-
-
Save emplv/0c4551112a3443cb23f13617962306f8 to your computer and use it in GitHub Desktop.
AoC 2019 - day 4
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 = '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