Hey,
I need to build a full "number range" set given a series of numbers. I start with a list such as :
ID START
* 0
a 4
b 70
c 700
d 701
e 85
- where "def" is the default range & should "fill-in" the gaps
- "overlaps" are value (70, 700, 701) in starting data
And need the following result:
ID START END
* 0 - 39
a 4 - 49
* 5 - 69
c 700 - 7009
d 701 - 7019
b 702 - 709
* 71 - 849
e 85 - 859
* 86 - 9
What I am trying to figure out is if there is some sort of algorithm out there or design pattern to tackle this. I have some ideas but I thought I'd run it by the "experts" first. I am using Python.
Any ideas / direction would be greatly appreciated. Some initial ideas I have:
- Build a "range" list w/ the start & end values padded to the full length. So default would be 0000 to 9999
- Build a "splits" list that is built on the fly
- Loop through "range" list comparing each value to the values in the splits list.
- In the event that an overlap is found, remove the value in the splits list and add the new range(s).