Created
December 4, 2017 14:25
-
-
Save ldd/269cf1f1287994af3a0f1724063c5efb to your computer and use it in GitHub Desktop.
Advent of code - Day 1 (javascript)
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
// 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