Java - 126 characters
minimized:
class hjq{public static void main(String...w){for(char z='"'|0;++z!='a';)if("'()+.0;=OS".indexOf(z)==~0)System.out.print(z);}}
unminimized:
class hjq {
public static void main(String... w) {
for (char z = '"'|0; ++z != 'a';) {
if ("'()+.0;=OS".indexOf(z) == ~0) {
System.out.print(z);
}
}
}
}
This is an interesting problem, because individual tokens might benefit from their longer form because it re-uses characters. For example, normally String[]
would be shorter, but String...
removes the need for the square brackets in the conditional string.
I found the trick was to try and use characters at the beginning and end of the range so you can exclude them from the output simply by altering your loop start and end.
For Java, a key character to exclude is "
, because having that in the string requires escaping it, which adds \
to your program, which needs to go in the string, which adds \\
. By removing "
from your conditional string you remove 4 characters. This can be achieved by making sure you use
and !
and starting your loop from #
.
All the lowercase letters appear near the end of the range, with only {
, |
, }
and ~
coming after them. Because of Java's verbosity, most of the lowercase letters are used just for the boilerplate. Likewise, {
and }
are trivial for a Java program, because the boilerplate requires them.
|
can be used if you have an or condition, but I couldn't find a way to take advantage of one that leads to a shorter program than just using |
as a bitwise operator. The |0
makes me feel a little dirty, because it's the only part that's a nop just to get the character in there.
~0
yields -1
, which is handy because that's what we need to check for with indexOf
. Combining this with using !=
for the loop conditional eliminates the <
character altogether, which means it doesn't need to go inside the conditional string.
0x20
to0x7e
, which are defined as the "printable ASCII characters". Technically tabs and newlines are actually control characters. \$\endgroup\$