I have two ranges of numbers and I need to determine if they overlap or adjacent and if so return a new range containing the values. The values are low and high for each pair, such that the first value of the tuple is always less than or equal to the second value in the tuple.
for example: a = (0, 5) b = (5, 10) print getAdjacent(a, b) # output: (0, 10) print getAdjacent(b, a) # output: (0, 10) print getOverlap(a, b) # output: None print getOverlap(b, a) # output: None a = (0, 7) b = (3, 10) print getAdjacent(a, b) # output: None print getAdjacent(b, a) # output: None print getOverlap(a, b) # output: (0, 10) print getOverlap(b, a) # output: (0, 10) a = (0, 90) b = (5, 10) print getAdjacent(a, b) # output: None print getAdjacent(b, a) # output: None print getOverlap(a, b) # output: (0, 90) print getOverlap(b, a) # output: (0, 90) a = (0, 5) b = (12, 20) print getAdjacent(a, b) # output: None print getAdjacent(b, a) # output: None print getOverlap(a, b) # output:None print getOverlap(b, a) # output: None any easy way of doing this? -- http://mail.python.org/mailman/listinfo/python-list