Skip to content

Instantly share code, notes, and snippets.

@tekerson
Created Dec 1, 2017
Embed
What would you like to do?
Advent of Code 2017 - JavaScript
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)
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