Right now I stuck with a problem. It seems to be really trivial one, but still it is hard for me to find an appropriate solution. The problem is: One has two intervals and are to find the intersection of them.
- Intersection of [0, 3]&[2, 4] is [2, 3]
- Intersection of [-1, 34]&[0, 4] is [0, 4]
- Intersection of [0, 3]&[4, 4] is empty set
It is pretty clear that the problem can be solved by using tests of all possible cases, but it will take a lot of time and is very prone to mistakes. Are there any easier way to tackle the problem? If you know the solution help me, please. Will be very grateful.