Вам просто нужно пересечь диапазоны.Вот как в псевдокоде:
// An array that has the ranges (inequalities) to test:
fromToArray = [[0, 10], [5, 20], [-5, Infinity]]
currentRange = [-Infinity, Infinity];
for each pair myRange in fromToArray
if currentRange[0] < myRange[0]
then currentRange[0] = myRange[0]
if currentRange[1] > myRange[1]
then currentRange[1] = myRange[1]
if currentRange[0] >= currentRange[1] // from greater than to, so set is empty.
then return "NO SOLUTION"
end for each
return "Solution is: " + currentRange