Skip to content

Instantly share code, notes, and snippets.

@MadaraUchiha
Created December 16, 2015 16:35
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 MadaraUchiha/ad943defbdacf0d19f95 to your computer and use it in GitHub Desktop.
Save MadaraUchiha/ad943defbdacf0d19f95 to your computer and use it in GitHub Desktop.
const next = input => {
let chars = input.match(/(\d)\1*/g);
return chars.map(repetition => `${repetition.length}${repetition[0]}`).join('');
};
const nextN = (input, times) => {
if (times === 0) {
return input;
}
return nextN(next(input), times - 1);
};
console.log(nextN(input, 50).length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment