Skip to content

Instantly share code, notes, and snippets.

@anoam
Created October 9, 2013 10:30
Show Gist options
  • Save anoam/6899250 to your computer and use it in GitHub Desktop.
Save anoam/6899250 to your computer and use it in GitHub Desktop.
class Sequence
def initialize(first_element)
@current_element = first_element.to_s
end
def to_s
@current_element
end
def next
next_step
self
end
private
def next_step
@current_element = @current_element.scan(/((\d)\2*)/).map{|element| "#{element.first.size}#{element.last}"}.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment