find a gap between1/5 5/9
Answers
So you mean you're looking for a way to identify the biggest gap in between the numbers and insert the median of the two so that the gap is "bridged"? Anyways, here's what I came up with:
Let's take your last example set, {1,2,5,10,28,3,4,8,9,12}{1,2,5,10,28,3,4,8,9,12}. Should the numbers be in that order or does order not matter?
If order does matter
Simply take the absolute value of each difference between each two adjacent numbers, like this:
|1−2|=|−1|=1|1−2|=|−1|=1
|2−5|=|−3|=3|2−5|=|−3|=3 ... and so on.
Find the largest of such differences (in this case, it's |28−3|=25|28−3|=25.) This difference is the largest and thus has the largest gap between them. Then take the two numbers which have this difference, 28 and 3, and compute their average, rounded down. In code, just use the floor() function to round down: ⌊(28+3)2⌋=15⌊(28+3)2⌋=15 (the ⌊x⌋⌊x⌋ notation means round down.)
So your number will be 15.