Skip to content

Instantly share code, notes, and snippets.

@joawan
Created December 10, 2017 20:08
Show Gist options
  • Save joawan/8ae2fc2de8468e815923496e4b0a984e to your computer and use it in GitHub Desktop.
Save joawan/8ae2fc2de8468e815923496e4b0a984e to your computer and use it in GitHub Desktop.
AoC 2017, Day 1, oneliner
console.log(process.argv[2].split('').filter((e, i, a) => e === a[(i + 1) % a.length]).reduce((s, c) => s + +c, 0));
console.log(process.argv[2].split('').filter((e, i, a) => e === a[(i + a.length / 2) % a.length]).reduce((s, c) => s + +c, 0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment