Skip to content

Instantly share code, notes, and snippets.

@bricker
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save bricker/514b4b92189d8fec9e4c to your computer and use it in GitHub Desktop.

Select an option

Save bricker/514b4b92189d8fec9e4c to your computer and use it in GitHub Desktop.
RANGE_MIN = 360
RANGE_MAX = 1140
def fill_gaps(ranges)
gaps = []
last_rng_end = RANGE_MIN
ranges.each do |rng|
if rng[0] > last_rng_end
gaps << [last_rng_end, rng[0]]
last_rng_end = rng[1]
end
end
if last_rng_end < RANGE_MAX
gaps << [last_rng_end, RANGE_MAX]
end
gaps
end
puts fill_gaps([[480, 720], [780, 840], [1020, 1080]]).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment