Range of numbers
APL (39)
'QWERT'/⍨1↓⊃≠/1 0⌽¨0,¨0 7 18 32 135∘<¨⎕
Takes input as two whitespace-separated numbers.
Explanation:
0 7 18 32 135∘<¨⎕
: For each number in the input, see if 0, 7, 18, 32, and/or 135 is smaller than the number. If the input was5 27
we now have(1 0 0 0 0) (1 1 1 0 0)
. (The first one is taken to be the start of the line and the second one the end).1 0⌽¨0,¨
: Prefix a zero to each of those lists and rotate the first one left by 1. (We now have(1 0 0 0 0 0) (0 1 1 1 0 0)
).≠/
: Gives a list where the individual items of the two input lists were not equal. (We now have1 1 1 1 0 0
).1↓⊃
: Remove the first item from this list. The other five stand for whether or not to display a Q, W, E, R or T.'QWERT'/⍨
: For each letter, output N of those letters, where N is the corresponding value in the list on the right. Since the list was1 1 1 0 0
the answer isQWE
.
Python 82 84
There you are. Edit: Fixed for inputs like -1 10
and -10 -1
for 2 chars
z=lambda a:(a>7)+(a>18)+(a>32)+(a>135)+1
a,b=input()
print"QWERT"[z(a)-1:z(b)*(b>0)]
GolfScript (43 32 30 chars)
Contains escape characters. As a hex dump:
00000000 7e 29 27 51 08 57 0b 45 0e 52 67 27 32 2f 7b 29 |~)'Q.W.E.Rg'2/{)|
00000010 2a 7d 25 27 54 27 32 24 2a 2b 3c 3e 2e 26 |*}%'T'2$*+<>.&|
Base-64 encoded:
fiknUQhXC0UOUmcnMi97KSp9JSdUJzIkKis8Pi4m
Using bold to indicate escape characters:
~)'Q^HW^KE^NRg'2/{)*}%'T'2$*+<>.&
Thanks to Howard for the suggestion to use escape characters.