Created
March 10, 2016 15:19
-
-
Save jooyunghan/2550c2841996bb03f01d to your computer and use it in GitHub Desktop.
Print look-and-say sequence using Regex/Generator
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
| const ant = function *(s = "1") { | |
| yield s; | |
| yield* ant(s.replace(/(.)\1?\1?/g, g => g.length + g[0])); | |
| } | |
| for (var i=0, a = ant(); i++<10; ) { | |
| console.log(a.next().value) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment