Last active
August 29, 2017 20:45
-
-
Save ghaiklor/8549a92b6ca6975602aa to your computer and use it in GitHub Desktop.
Advent of Code (Day 10 Part 1)
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 INPUT = '1113122113'; | |
const FIND_REPETITIONS_REGEX = /(\d)\1*/g; | |
const lookAndSay = input => input.match(FIND_REPETITIONS_REGEX).reduce((acc, char) => acc + `${char.length}${char[0]}`, ''); | |
let result = INPUT; | |
for (let i = 0; i < 40; i++) { | |
result = lookAndSay(result); | |
} | |
console.log(result.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment