Skip to content

Instantly share code, notes, and snippets.

@ldd
Created December 4, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldd/269cf1f1287994af3a0f1724063c5efb to your computer and use it in GitHub Desktop.
Save ldd/269cf1f1287994af3a0f1724063c5efb to your computer and use it in GitHub Desktop.
Advent of code - Day 1 (javascript)
// day 1
const day1part1 = s => s
.split('')
.filter((el,i,A)=>(el===A[(i+1) % A.length] ))
.reduce((p,n)=>p+(+n),0)
const day1part2 = s => s
.split('')
.filter((el,i,A)=>(el===A[(i+A.length/2) % A.length]))
.reduce((p,n)=>p+(+n),0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment