25
\$\begingroup\$

In this question I asked you to guess an anagram quine based on its output. However it looks like we don't have a question asking to golf an anagram quine yet. So your task will be to make the shortest anagram quine that you can.

What is an anagram quine?

An anagram quine is a non empty program that prints an anagram of its source code, other than its original source.

Here's an example of an anagram quine in Python 2:

print`'`print`*2'*2`

You should not read your own source for this challenge.

\$\endgroup\$
8
  • 2
    \$\begingroup\$ @LeakyNun No, It can't be a quine. \$\endgroup\$
    – Wheat Wizard
    Commented Jun 7, 2017 at 17:21
  • 2
    \$\begingroup\$ Does the outputted code have to be a valid program? \$\endgroup\$
    – MD XF
    Commented Jun 7, 2017 at 17:43
  • 1
    \$\begingroup\$ @MDXF No it does not. \$\endgroup\$
    – Wheat Wizard
    Commented Jun 7, 2017 at 18:38
  • 2
    \$\begingroup\$ @Okx It should follow our standard requirements for a quine (other than it being a quine). \$\endgroup\$
    – Wheat Wizard
    Commented Jun 7, 2017 at 18:39
  • 1
    \$\begingroup\$ @LeakyNun Mind you, I don't think 0-byte programs have anagrams that differ from the original either! \$\endgroup\$
    – Neil
    Commented Jun 7, 2017 at 19:52

42 Answers 42

1
2
1
\$\begingroup\$

Keg, 8 bytes

`.,:`:,.

Try it online!

A rearrangement of the usual quine.

\$\endgroup\$
0
\$\begingroup\$

05AB1E, 13 bytes

"34çJ∞"34çJ∞

Outputs:

34çJ∞""∞Jç43

Try it online!

"34çJ∞"      # Push this string                 | [ 34çJ∞ ]
       34ç   # Push a quote (")                 | [ 34çJ∞, " ]
          J  # Join                             | [ 34çJ∞" ]
           ∞ # Mirror                           | [ 34çJ∞""∞Jç43 ]
             # Implicitly output with a newline
\$\endgroup\$
0
\$\begingroup\$

C, 60 bytes

main(s){printf(s="main(s){s=printf(%c%s%1$c,34,s);}",34,s);}

Just the shortest C quine with trivial modifications.

Output:

main(s){s=printf("main(s){s=printf(%c%s%1$c,34,s);}",34,s);}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

shortC, 34 bytes

Bs){Rs="Bs){s=R%c%s%1$c,34,s",34,s

Output:

Bs){s=R"Bs){s=R%c%s%1$c,34,s",34,s

Try it online!

\$\endgroup\$
0
\$\begingroup\$

str, 10 bytes

`2xr;`2xr;

Try it online! Outputs `2xr;2xr;`

`2xr;`2xr;
.........;   preamble
`2xr;`       a string containing those character
      2x     repeat twice
        r    print the representation of that doubled string
         ;   end preamble (no program)
\$\endgroup\$
0
0
\$\begingroup\$

Jelly, 7 bytes

“ØvṚ”Ṙv

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Braingolf, 36 32 bytes

"V#!1+!@@R!&@&@;"V#!1+!@@R!&@&@;

Try it online!

Outputs ""V#!1+!@@R!&@&@;V#!1+!@@R!&@&@;, which is the source, but with both " at the start, the ; is required at the end to prevent a trailing newline

Explanation:

"V#!1+!@@R!&@&@;"V#!1+!@@R!&@&@;  
"V#!1+!@@R!&@&@;"                 Pushes the charcode of each char in the string
                 V                Create stack2 and switch to it
                  #!              Push charcode of !
                    1+            Increment to charcode of "
                      !@@         Print twice, popping the 2nd time
                         R        Return to stack1
                          !&@&@   Print entire stack twice, popping the 2nd time
                               ;  Suppress implicit output to prevent trailing newline

Alternatively (not sure this one actually meets the requirement of it being a proper quine):

Braingolf, 2 bytes


1

\n1, outputs 1\n

Explanation:

\n1
\n   No-op, does nothing
  1  Pushes 1
     Implicit output of last item on stack plus trailing newline
\$\endgroup\$
0
\$\begingroup\$

Java 8, 88 bytes

v->{String s="-v>{String s=%c%s%1$c;return s.format(s,34,s);}";return s.format(s,34,s);}

Outputs with both v and - swapped as anagram:

-v>{String s="-v>{String s=%c%s%1$c;return s.format(s,34,s);}";return s.format(s,34,s);}

Explanation:

Try it online.

  • The String s contains the unformatted source code (with - and v swapped to make it an anagram.
  • %s is used to input this String into itself with the s.format(...).
  • %c, %1$c and the 34 are used to format the double-quotes.
  • s.format(s,34,s) puts it all together.
\$\endgroup\$
0
\$\begingroup\$

Microscript II, 8 bytes

"phq"pqh

Microscript, 11 bytes (also a reverse quine):

0"Caxq"Caxq
\$\endgroup\$
0
\$\begingroup\$

Jelly, 6 bytes

00,”ṘṘ

Try it online!

Output is

0,”Ṙ0Ṙ
\$\endgroup\$
0
\$\begingroup\$

GolfScript, 8 bytes

{}*{.*}.

Output is {.*}{.*}

Works because the first three characters are garbage to find a way to get another set of braces in the program that don't show up.

If you don't care about whitespace, then {+}{.}+. outputs {+ .}{+ .}, which was my first attempt.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Excel, 38 bytes

=REPT("=REPT(CHAR(34),2)&"&CHAR(34),2)

Output is:

=REPT(CHAR(34),2)&"=REPT(CHAR(34),2)&"

If you sort and concatenate the characters from either, you get this:

""&&(((()))),,==223344AACCEEHHPPRRRRTT
\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.