Skip to content

Instantly share code, notes, and snippets.

@mneumegen
Last active March 22, 2016 21:40
Show Gist options
  • Save mneumegen/b81701815b7fd235209f to your computer and use it in GitHub Desktop.
Save mneumegen/b81701815b7fd235209f to your computer and use it in GitHub Desktop.
require 'json'
input = "[[0,5,6,11,15],[12,24,63],[17,28,50]]"
input = JSON.parse(input)
start = Time.now
min_column = input.map{|a| a[0]}
max = min_column.max
second_smallest = min_column.sort[1]
min = input[min_column.index(min_column.min)].max_by do |x|
if x > second_smallest
x = -1
end
x
end
puts "Range: #{min} - #{max}"
puts (Time.now - start).to_f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment