Skip to content

Instantly share code, notes, and snippets.

@ericwo
Last active August 29, 2015 14:26
Show Gist options
  • Save ericwo/86dfb24af83564f02509 to your computer and use it in GitHub Desktop.
Save ericwo/86dfb24af83564f02509 to your computer and use it in GitHub Desktop.
The Telegram Problem
class Telegram
attr_reader :elements
def initialize file
context = File.open(file).read
context.gsub!("\n", ' ')
@elements = context.split(' ')
end
def container
return false if @elements.length <= 0
length = 30
temp_array = []
@elements.each do |element|
if element.length < length
print "#{element} "
temp_array.push element
length = length - element.length - 1
else
@elements = @elements - temp_array
print "\n"
return
end
end
@elements = @elements - temp_array
end
def printer
while @elements.length > 0
container
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment