-
-
Save bricker/514b4b92189d8fec9e4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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