Skip to content

Instantly share code, notes, and snippets.

@LeftyBC
Created November 9, 2018 20:12
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 LeftyBC/7dc91c26dcc9f0bb2912bc3e2633f699 to your computer and use it in GitHub Desktop.
Save LeftyBC/7dc91c26dcc9f0bb2912bc3e2633f699 to your computer and use it in GitHub Desktop.
working solution
n = 5
lines = Array.new(n)
for i in 0..(n-1)
lines[i] = 0
end
File.readlines("test").each do |item|
item = item.to_i
for i in 0..(n-1)
if item > lines[i]
lines[i] = item
break
end
end
end
puts lines.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment