Created
March 5, 2012 18:18
-
-
Save IlyaEremin/1980113 to your computer and use it in GitHub Desktop.
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
def look_and_say(number, iterate) | |
number = number.to_s | |
iterate.times do | |
puts number | |
number = number.gsub(/(.)\1*/) {|s| "#{s.size}#{s[0]}"} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment