We all know what a quine is. An inverted quine is a non-empty program that prints the inverse of its source code without reading its source code, and consists solely of printable-ASCII characters (space through ~).

Here, “inverse of the source code” means the following: the output of your program must contain each printable ASCII character (m − c) times, where c is the number of times said character occurs in your code, and m is the maximum number of times any character is repeated in your code.

(In other words: your code + your output = permutation of m times all of printable-ASCII.)

For example, if your program is 12345, then m = 1, and you should output any permutation of this string:


If your program is AAB, then m = 2, and you should output any permutation of:


Note how there are two missing As, and one missing B.

Although a program that contains all the printable ASCII characters and outputs nothing is a valid inverse quine (satisfying m = 1), such an answer would not be very competitive, given its length.

You are to write a program that is an inverted quine, as described in the above paragraph. As this is , the shortest program in bytes will win. Good luck!

  • 1
    \$\begingroup\$ Space, tab and newline? \$\endgroup\$ Oct 18, 2017 at 12:49
  • 11
    \$\begingroup\$ You should highlight the duplicated for every repeated character in the source code it makes all the difference in the challenge \$\endgroup\$
    – Rod
    Oct 18, 2017 at 12:53
  • 6
    \$\begingroup\$ Could you give an example of the inverse where multiple characters are repeated (and multiple times)? Say, 11234512345? \$\endgroup\$
    – Giuseppe
    Oct 18, 2017 at 12:55
  • 4
    \$\begingroup\$ How is this a duplicate? Related, yes. Duplicate, no! It's way more difficult in languages where you have to have duplicate characters. Note that you can't just duplicate a string either, since the number of characters you must remove from each string is varying. \$\endgroup\$ Oct 18, 2017 at 15:55
  • 1
    \$\begingroup\$ @StewieGriffin I would VTC this as "unclear" rather than a "dupe" because (nearly) every answer has a comment trying to figure out what duplicated for every repeated character in the source code means or if the submission is valid for that criterion, because the OP hasn't addressed quite a few of the questions here. \$\endgroup\$
    – Giuseppe
    Oct 18, 2017 at 17:02

6 Answers 6


Brain-Flak, 221 207 bytes

Includes +1 for -A


Try it online!

# Push 206 (the number of times to duplicate the output)

# For 0 to 206

    # Push 32 on this stack and 18, 28 and 29 to the other
    # 18, 28 and 29 are the distances between the sets of braces 

    # For 0 to 8

        # Push TOS, TOS + 1

    # end For 0 to 8

    # Push TOS + 2 
    # skips '(' and ')'

    # For each value on the off stack (18, 28, 28)

        # For 0 to that number

            # Push TOS, TOS + 1

        # End for 0 to that number

        # Push TOS + 1, TOS + 3 (skips this set of braces)

    # End for each value on the off stack (18, 28, 28)

 # End for 0 to 206
  • \$\begingroup\$ I think you should only remove [ five times, not all times. Note that 2 is only removed once in the example. The challenge is a bit confusing though. \$\endgroup\$ Oct 18, 2017 at 16:11
  • \$\begingroup\$ Interesting how this is drastically shorter than the standard quine. +1 :) \$\endgroup\$
    – DJMcMayhem
    Oct 18, 2017 at 16:16
  • 2
    \$\begingroup\$ This is really lame, and significantly less interesting than your answer, but technically, !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~` would get a better score :/ \$\endgroup\$
    – DJMcMayhem
    Oct 18, 2017 at 16:48

CJam, 17 bytes


Try it online!




The goal was to modify the standard quine


such that no character is repeated in the program. The reason for this is that CJam has a set different operator which we can use to remove characters from the printable ASCII range, but it doesn't take number of occurrences into account. Implementing that by hand would probably be longer, so I needed to make sure that every character appears only once and we don't have to worry about occurrences.

{      e# Quine framework. Executes the block while leaving another copy of the
       e# block on the stack.
  s    e#   Stringify the block, giving us "{s95c+'|,32>\-}".
  95c  e#   Convert 95 to a character, which gives us '_' without repeating
       e#   it in the source code.
  +    e#   Append it to the string. We don't need to worry about '~', we'll just
       e#   leave it out of the printable ASCII range to begin with.
  '|,  e#   Get a character range from the null byte up to '{'. This omits "|}~",
       e#   but those are in the program anyway, it doesn't matter.
  32>  e#   Discard the unprintable characters.
  \-   e#   Subtract the source string from the printable ASCII range.

Python 3, 83 bytes


Try it online!

Prints -0.375 False.


05AB1E, 95 61 60 bytes (not 58 b/c I dislike that one)

A?9L<J, !"'#$%&()*+-./:;=>@BCDEFGHIKMNOPQRSTUVWXYZ[\]^_`{|}~

Try it online!

Old answer invalidated by "only-ASCII characters", a lot of commands aren't valid here.

It prints abcdefghijklmnopqrstuvwxyz012345678 one time as there are no duplicated characters.


Work in progress... I think ~60 bytes is as low as you get without non-ASCII characters in 05AB1E..

05AB1E, 58 bytes

T5+FA'uK?Au"ADLJFKST"SK?9L<5KJ?} !#$%&()*>-./:;=@[]^_`{|~\

Try it online!

Prints the output x12 due to the repeated characters:

['""', '55', '???', 'AAA', 'FF', 'JJ', 'KKKK', 'LL', 'SS', 'TT', 'uu']

It also doesn't terminate quite correctly, working on that now...

Invalid old answers (due to non-ASCII characters) have been removed, see edit history.

  • \$\begingroup\$ "An inverted quine is a non-empty program that prints the inverse of its source code without reading its source code, and consists solely of printable-ascii characters." I was working on an 05AB1E answer, too, until I noticed this. \$\endgroup\$
    – KSmarts
    Oct 18, 2017 at 13:50
  • 1
    \$\begingroup\$ @KSmarts fixed at a cost of 76 bytes. \$\endgroup\$ Oct 18, 2017 at 13:53
  • 2
    \$\begingroup\$ Typically, in a code-golf challenge, one would expect 05AB1E to do a little better than, "beats Java". \$\endgroup\$
    – KSmarts
    Oct 18, 2017 at 13:54
  • \$\begingroup\$ @KSmarts shrug if you don't let esolangs easily compete by definition, you deserve a sarcastic esolang answer :P. \$\endgroup\$ Oct 18, 2017 at 13:55

Java 8, 106 99 190 bytes

class i {/*{}!"#$%&'()+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bdefghjkmnopqrtuvwxyz|~!"#$%&'()+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`claibdefghjkmnopqrtuvwxyz|~*/}
  • \$\begingroup\$ You can probably golf it by removing the space in i { because you already have a space \$\endgroup\$
    – Okx
    Oct 18, 2017 at 13:30
  • 1
    \$\begingroup\$ I believe that every character must occur the same number of times for this to be valid \$\endgroup\$ Oct 18, 2017 at 13:33
  • \$\begingroup\$ I'm not sure if I understand the challenge completely, but isn't just class i{/*!"#$%&'()+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bdefghjkmnopqrtuvwxyz|~*/} enough? It contains all printable-ASCII in it's source code, and outputs nothing. The part "duplicated for every repeated character in the source code" applies to the output, so even though s is duplicated in class and * and / are duplicated due to /* */, outputting four times nothing is still nothing. \$\endgroup\$ Oct 18, 2017 at 14:31
  • \$\begingroup\$ Also, if I'm indeed correct, you can also golf it to: interface Z{}//!"#$%&'()*+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY[\]^_`bdghjklmopqsuvwxyz|~ (97 bytes) \$\endgroup\$ Oct 18, 2017 at 14:37

Javascript (ES6), 103 101 bytes

_=>` !"#$%&'()*+,-.0123456789:;<?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^abcdefghijklmnopqrstuvwxyz{|}~`//_=>\\

Old solution (103 bytes using alert)

alert;;alert`\ \!"#$%&'()*+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_bcdfghijkmnopqsuvwxyz{|}~`

Old (invalid) solution (96 bytes)

alert()// !"#$%&'*+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bcdfghijkmnopqsuvwxyz{|}~
  • \$\begingroup\$ You have two //, which means you must output the printable characters, with one / removed. (I think) \$\endgroup\$ Oct 18, 2017 at 16:06
  • \$\begingroup\$ @StewieGriffin Fixed \$\endgroup\$
    – Endenite
    Oct 18, 2017 at 16:25

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.