Print a Symbolic Negative of your Code

18

(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.

Luke

Posted 2015-10-14T16:52:25.023

Reputation: 5 091

Is this really a "quine" type challenge since the output doesn't need to be source code of any type? – Liam – 2015-10-17T08:13:48.970

Good point, I don't think it actually is. – Luke – 2015-10-19T13:58:03.550

@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. – Martin Ender – 2015-10-19T14:13:46.750

1Define "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"? – Conor O'Brien – 2015-10-19T14:25:22.203

Answers

11

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.

Dennis

Posted 2015-10-14T16:52:25.023

Reputation: 196 637

11

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

Dennis

Posted 2015-10-14T16:52:25.023

Reputation: 196 637

10

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 as 0.5, ; terminates the statement (does nothing in this case)

Fabian Schmengler

Posted 2015-10-14T16:52:25.023

Reputation: 1 972

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! – Dennis – 2015-10-14T20:07:30.527

5

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

Luke

Posted 2015-10-14T16:52:25.023

Reputation: 5 091