Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Forked from anonymous/solution1.rb
Created June 23, 2014 16:02
Show Gist options
  • Save timurvafin/238f26a3ddc4c388359d to your computer and use it in GitHub Desktop.
Save timurvafin/238f26a3ddc4c388359d to your computer and use it in GitHub Desktop.
result = [1]
loop do
p result.join
new_result = []
result.each do |elem|
if elem == new_result.last
new_result[-2] += 1
else
new_result.push(1, elem)
end
end
result = new_result
break if gets == "exit\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment