Came over a similar problem in a project I'm working on and found it quite hard to solve it without excesive use of if. I'm eager to see if anyone can come up with more elegant solutions to this, with the aribitary numbers I have given to the line segments.
The problem
You are given two integers that act like the end points of a line segment. Determine what existing line segments this line will overlap with.
Intervals / line segments
The other lines, named Q, W, E, R and T, are as following:
Q: 0 - 7
W: 8 - 18
E: 19 - 32
R: 33 - 135
T: 136 -
The last one, T, starts at 136 and has no end point.
Example
Given the numbers 5 and 27, the line will overlapp with Q, W and E. This can be roughly illustrated like this:
Q W E R T
---+--+---+-------+-----------+-----
0 7 18 32 135
+---------+
5 27
(somewhat arbitrary scale)
Input
Two integers from stdin.
Output
A String containing the names of the lines that our new line overlap with, for instance in the example above QWE.
Rules
Shortest code.

18and32should giveWEright? – grc Jun 11 '12 at 11:51