Skip to content

Instantly share code, notes, and snippets.

@IlyaEremin
Created February 25, 2012 09:17
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 IlyaEremin/1907474 to your computer and use it in GitHub Desktop.
Save IlyaEremin/1907474 to your computer and use it in GitHub Desktop.
def sequence(first_number, amount)
num = first_number.to_s.split(%r{\D*})
itteration = 0
while itteration < amount
string=""
count = 0
num.each do |f|
a ||= f
if (a == f)
count++
else
string += "#{count}#{a}"
a = nil
count = 0
end
end
puts string
itteration++
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment