(This is a variation on Print a Negative of your Code, which I enjoyed a lot! Thanks to Martin Büttner♦ - almost all of this text is his.)
Let's consider the symbols to be the following printable ASCII characters (note that space is included):
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
And the alphanumerics to be these:
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
Consider a square of printable ASCII characters for side length N, like the following:
ONE,
{two}
&3,+=
!four
f|ve.
We also require each row and each column to contain at least one symbol and one alphanumeric. (The above example satisfies this.)
We define the symbolic negative of such a square to be a square of the same size where each symbol is replaced with an alphanumeric and vice versa. For example, the following would be a valid symbolic negative of the above example:
[&]OK
a...b
1/100
i@#$%
(R) z
The choice of specific characters is irrelevant as long as they are in the categories above.
The Challenge
Your task is to write a program with square source code with side length N> 1, which prints a symbolic negative of its source code to STDOUT. Trailing spaces must be printed. You may or may not print a single trailing newline.
The usual quine rules also apply, so you must not read your own source code, directly or indirectly. Likewise, you must not assume a REPL environment which automatically prints the value of each entered expression.
The winner is the program with the lowest side length N. In the event of a tie, the submission with the fewest symbols in the source code wins. If there's still a tie, the earliest answer wins.
-
\$\begingroup\$ Is this really a "quine" type challenge since the output doesn't need to be source code of any type? \$\endgroup\$Liam– Liam2015年10月17日 08:13:48 +00:00Commented Oct 17, 2015 at 8:13
-
\$\begingroup\$ Good point, I don't think it actually is. \$\endgroup\$Luke– Luke2015年10月19日 13:58:03 +00:00Commented Oct 19, 2015 at 13:58
-
\$\begingroup\$ @LiamNoronha I'd consider it a generalised quine in that the output is a function of the source code, and the standard quine rules apply. \$\endgroup\$Martin Ender– Martin Ender2015年10月19日 14:13:46 +00:00Commented Oct 19, 2015 at 14:13
-
1\$\begingroup\$ Define "reading your own source code"; if there is a command that, say, copies characters to the output, would this be an instance of said "reading"? \$\endgroup\$Conor O'Brien– Conor O'Brien2015年10月19日 14:25:22 +00:00Commented Oct 19, 2015 at 14:25
4 Answers 4
GolfScript, 3 × 3 (4 symbols)
4,m
`3/
n*o
Try it online on Web GolfScript.
Output
[0
1 2
3]
How it works
4, # Push the array [0 1 2 3].
m # Undefined token. Does nothing.
` # Push the string representation of the array. Pushes "[0 1 2 3]".
3/ # Split into chunks of length 3. Pushes ["[0 " " 1 " "2 3]"].
n* # Join the chunks, separated by linefeeds. Pushes the output.
o # Undefined token. Does nothing.
CJam, 3 × 3 (5 symbols)
[5,
S*3
/N*
Try it online in the CJam interpreter.
How it works
[ e# Unmatched [. Does nothing.
5, e# Push [0 1 2 3 4].
S* e# Join the integers, separating by spaces. Pushes "0 1 2 3 4".
3 e#
/ e# Split into chunks of length 3. Pushes ["0 1" " 2 " "3 4"].
N* e# Join the chunks, separated by linefeeds. Pushes the output.
Output
0 1
2
3 4
Pyth, 3x3, 4 Symbols
S]1
.5;
S]1
Output:
[1]
0.5
[1]
Explanation:
- S sorts the one element list
]1
- The numeric literal
.5
gets printed as0.5
,;
terminates the statement (does nothing in this case)
-
\$\begingroup\$ I though long and hard about how I could get
<alphanum><symbol><alphanum>
in Pyth or CJam. It never occurred to me to use floats... Nice work! \$\endgroup\$Dennis– Dennis2015年10月14日 20:07:30 +00:00Commented Oct 14, 2015 at 20:07
C++, 18 x 18
"Always choose the worst tool for the job."
#include<cstdio>
int main(){ for (
int line = 0lu;
1lu*line < 18l;
1lu*line++){pri\
ntf(line == 0lu *
123*line? "\x41.\\
x2e\x02e...\x2e\\
x42\x02e...\x2e.\
CDE\x00a": 14l!=
1lu*line?".\x2e.\\
x46\x02e...\x47""\
HIJ\x02e..""KLM"
/*O*/"\n": /*The
bad code:*/"NOP.\
QRS\x054." "UVW\
XYZ\x02e" "\x2e\\
x2e\x00a"); 0lu;}}
Output:
A.......B......CDE
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
NOP.QRST.UVWXYZ...
...F....GHIJ...KLM
...F....GHIJ...KLM
...F....GHIJ...KLM
Explore related questions
See similar questions with these tags.