Created
December 1, 2017 23:01
-
-
Save tekerson/cb5af2c573ed114f05e42d6950db1710 to your computer and use it in GitHub Desktop.
Advent of Code 2017 - JavaScript
This file contains 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 solve = (input) => input | |
.split('').map(v => parseInt(v, 10)) | |
.reduce((acc, value, i, list) => { | |
const pair = list[(i + 1) % list.length] | |
return acc + (value === pair ? value : 0) | |
}, 0) |
This file contains 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 solve = (input) => input | |
.split('').map(v => parseInt(v, 10)) | |
.reduce((acc, value, i, list) => { | |
const pair = list[(i + list.length / 2) % list.length] | |
return acc + (value === pair ? value : 0) | |
}, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment