17
3
In particular, use each of these symbols at least once in your source code:
! " # $ % & ' () * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
Symbols inside comments, string literals, regexps (or any other kinds of literals etc.) don't count (but their delimiters such as /**/
or ""
do count).
The program should not perform any action. It just has to compile and do nothing when run.
If for some reason some of the symbols cannot be used in the language of your choice, explain that rigorously (what and why must be excluded).
Update: A few answers used symbols withing regular expressions. I'd consider this a bit problematic, it's the same thing as putting them into string literals or comments (that's why I put etc. in that requirement). Please try without this. I also updated the requirement above.
Update: Shortest code wins (tagged as code-golf). As suggested, we'll most likely need some tie-breaker criteria. I suggest that if there is a tie, the winning one is the one in which the ASCII symbols appear as much ordered as possible. Formally: Filter out the first occurrence of each of the listed symbols from a program. This will result in a permutation on the listed symbols. The program with less inversion number of its permutation wins.
Update: I'd be happy to see some/more solutions in regular/mainstream languages, such as C(++), Java, Scala, Haskell, etc.
Is it required to do nothing, or is it just not required to do anything? – Matt – 2012-11-07T19:48:35.123
@Matt I'd prefer programs that do nothing, but don't consider it important, solutions that do something are also acceptable. – Petr Pudlák – 2012-11-07T20:01:06.463
1Can we have a literals exception for characters that do not appear in any keyword, syntax or operator in a particular language? That is neither
@%
nor the backtick can appear in c except as part of a literal (in sufficiently new versions of c%
can appear in digraphs). (and#
only appears in preprocessor directives, but we'll just have to live with that)? That is, I'm asking for Matt's approach to be made explicitly legal. – dmckee --- ex-moderator kitten – 2012-11-07T21:26:12.033For that matter what about
%
inprintf
format specifiers which are formally strings, but are in some sense part of the language? – dmckee --- ex-moderator kitten – 2012-11-07T21:44:21.4932shortest code wins? i suspect there will need to be a tie-breaking criteria too – ardnew – 2012-11-07T22:52:26.447
@dmckee I'd say
%
is inside a string literal so it should not be considered. – Petr Pudlák – 2012-11-08T06:06:07.127@dmckee,
%
is a C operator. But@$
and backtick are indeed problematic. – ugoren – 2012-11-08T07:25:50.597@ugoren Er...how could I forget modulus? ::sigh:: – dmckee --- ex-moderator kitten – 2012-11-08T15:45:38.217
1In Javascript, the characters
#
,@
, and ` are not legal outside of any sort of literal – Peter Olson – 2012-11-08T16:13:33.7836This is basically a competition of "find a language that can use all of these characters as syntax". Pretty crappy code gold in my opinion – Earlz – 2012-11-08T16:34:30.590
1Yea I agree with @Earlz, I think it would be better if it had to do something useful, in the lease amount of code, that way people couldn't just fluff to get all the characters in but it wouldn't be ardnew's solution. Cause as it stands you can't get shorter then that, plus any language in which some of the characters are not valid outside of literals - as has been pointed out by several people - are instantly disqualified. Which means there are only a few not only acceptable answers but correct answers period. – Ryan – 2012-11-08T20:41:57.277
@ryan I was thinking about requiring some goal. But I fear that the results will be programs that do the goal in one part and use all characters in another. If you think it's better, feel free to start your own similar code-golf question requiring some goal. Competition benefits customers. | And to your other objection, that's why I said If for some reason some of the symbols cannot be used in the language of your choice, explain that rigorously (what and why must be excluded). In other words, you can omit those characters that aren't available in your language, if you explain it. – Petr Pudlák – 2012-11-09T06:25:21.560