Ideally, I’d like a solution in Ruby or Javascript. Arrays instead of ranges in javascript would be fine.
I’d like input such as:
[0..301, 230..268, 242..364, 574..579, 587..593]
or
[0,301, 230,268, 242,364, 574,579, 587,593]
And turn it into something like:
[0..230, 230..242, 242..268, 268..301, 301..364, 574..579, 587..593]
or
[[0,230], [230,242, [242,268], [268,301], [301,364], [574,579, [587,593]]
Any help would be great. This sort of helps but not fully because it gives the full range instead of the chunked ranges, How do I summarize array of integers as an array of ranges?.
Here’s a ruby solution: