For this challenge, you will be required to write 3 programs:

  1. The first program should be a quine, i.e, it should print it's own source code.
  2. The second program should read the input and print all of it.
  3. The third program should simply print the string "Hello, Permutations!", with or without quotes.

In addition to that, all the three programs should be permutations, i.e, starting from any of the three programs, you should be able to obtain the other by re-arranging it's characters. So all programs will have the same byte count and frequency of characters. For example: abcd, dbca and adbc are permutations.


  • You may choose to write functions instead of programs.

  • For the first program, you are not allowed to read the source file and print it.

  • You only need to read the input for the second program. No input will be provided to the other two programs.

  • Standard loopholes are forbidden.

  • This is , so the shortest code (in bytes) wins.

  • \$\begingroup\$ Sandbox \$\endgroup\$ Commented Mar 14, 2021 at 7:31
  • \$\begingroup\$ Sorry if this should be obvious, but should the quine, if we choose to define a function, print only the body of the function, or the entire definition? \$\endgroup\$ Commented Mar 15, 2021 at 12:26
  • \$\begingroup\$ @ZaelinGoodman the entire definition. Check out the current answers, some of them use functions. \$\endgroup\$ Commented Mar 15, 2021 at 12:52
  • \$\begingroup\$ Are we allowed to have one program and two functions or two programs and one function? \$\endgroup\$
    – 79037662
    Commented Mar 15, 2021 at 13:49
  • \$\begingroup\$ @79037662 Yes.. \$\endgroup\$ Commented Mar 15, 2021 at 14:30

20 Answers 20


Underload (stringie), 33 bytes each

((aS(:^):SHello, Permuttions!):^)
(S(Hello, Permutations!)(:::^^S))
((Hello, Permutations!)S(:::^^S))

Try it online!

These are function submissions that input via the argument stack, but output to standard output. (The functions also produce garbage output using the more normal mechanism for function output, but according to our normal I/O rules, we only look in one place.)


(aS(:^):SHello, Permuttions!):^
(aS(:^):SHello, Permuttions!)     string literal
                             :    non-destructive
                              ^     eval
 a                                enclose {the string literal} in parens
  S                               print it
   (:^)                           string literal
        S                         print that too
       :                          retaining a copy
         Hello, Permuttions       no-ops
                           !      discard the retained copy

S(Hello, Permutations!)(:::^^S)
S                                 print {function input}
 (Hello, Permutations!)           string literal {2nd return value}
                       (:::^^S)   string literal {1st return value}

(Hello, Permutations!)S(:::^^S)
(Hello, Permutations!)            string literal
                      S           print it
                       (:::^^S)   string literal {return value}

If we weren't exploiting this site's I/O rules, it'd cost one extra byte (along with a little code rearrangement) to output the output we wanted (either to standard output or as the function return value), and delete the output we didn't want. But just leaving the extra characters that we're forced to use in order to make a permutation on the argument stack is very slightly shorter.

The quine is an eval quine: we write most of the program in a string literal and eval it, but we still have the original string literal available (because we made the eval non-destructive) and can print it in addition to running it. (This isn't code reading itself, rather the :^ reads one string and uses it for two different purposes.)

  • 2
    \$\begingroup\$ Why was this made community wiki? \$\endgroup\$
    – Jonah
    Commented Mar 14, 2021 at 17:17
  • \$\begingroup\$ @Jonah I think it's because ais523 doesn't want to take more rep. Look at all their other answers. \$\endgroup\$
    – user
    Commented Mar 14, 2021 at 19:59
  • \$\begingroup\$ Yeah I noticed that after I posted. Maybe ais523 doesn't like the whole idea of rep. \$\endgroup\$
    – Jonah
    Commented Mar 14, 2021 at 20:38
  • 1
    \$\begingroup\$ @Jonah: there's normally no real connection between the sorts of answers that get you lots of reputation and the sorts of answers that actually make the site better. I'd much rather be posting the latter than the former, and CWing all my posts helps to avoid any incentive to post answers purely to get upvotes. (It also makes my posts easier to edit – I think people should be editing posts more often, although I don't do it myself because there's an unavoidable +2 reputation gain for low-reputation post editors.) \$\endgroup\$
    – ais523
    Commented Mar 15, 2021 at 23:00
  • 3
    \$\begingroup\$ Yeah, I understand the argument and respect the decision. There's real purity to it. The silly points, despite their gamability and imperfect connection to quality, still give me some motivation though. \$\endgroup\$
    – Jonah
    Commented Mar 15, 2021 at 23:24

7, 58 56 characters, 22 21 bytes each


Try it online!


Try it online!


Try it online!

Update: Since the first version of this answer, I golfed off a 7 and a 0 – the hello program was slightly rearranged to be able to make use of the 6 rather than needing a 0, and the quine was entirely rewritten to use fewer 7s. The text below has been updated to match; see the edit history for the previous version of this answer.

No cheating with I/O this time: these are all full programs which output to standard output, and (in the case of the second program) input from standard input. The cat program was the hardest of the three to write by far, because it's the only program that requires a loop.

7's character encoding (which is just octal) encodes eight characters per three bytes. This program is thus 21 bytes long (⅜ of 56). Because this is an integer, we don't have to worry too much about the weird sub-byte encoding, but in order to make the programs "conceptually shorter", I ensured that they all ended with a 3 (the interpreter treats trailing 1 bits like trailing whitespace, so the final two bits of the encoding are arguably not part of the program). Note that I can't end a program with a 7 because it would be ignored entirely, causing the program to no longer be 56 characters long (and thus the programs to not be permutations of each other).


My usual reminder: 7 has 12 commands, but only 8 of them have names. I use the notation 0, 1, 2, 3, 4, 5 for the commands that append 6, 7, 2, 3, 4, 5 respectively to the top stack element (the last four of these commands cannot appear literally in a program and can only be created at runtime by using them to create a program on the stack).


00…55              An arbitrary string literal
     7             Separator between elements of the initial stack
      171622…53    Literal representing the main program

The first pass through a 7 program can't do anything more than push literals to the stack (the rightmost goes towards the top of the stack). However, after doing that, the top stack element is implicitly executed (non-destructively; it remains on top of the stack, and a copy is executed). It does the following:

71                     Push stack element "7"
  2                    Duplicate it
   23                  Use one copy as an I/O routine (sets I/O format 7)
     443               Swap the "7" and main program
        6              Uneval the main program, and
                         append it to the stack element below
         46            Uneval the second stack element, while
                         swapping it to the top of the stack
           46          Uneval the second stack element, while
                         swapping it to the top of the stack
             5         Execute the new top of stack
                         (this undoes the uneval and appends it
                          to the element below)
              3        Output (+ some irrelevant side effects)

It's a little hard to follow this, so here's a description of what's happening to the stack. It starts with two stack elements: the arbitrary literal, below the main program (both of these start out in evaluated, ready-to-run, form). The program immediately adds a third (the literal 7), which is (nondestructively) used to set the I/O format (to format 7, "the same format as is used for the source code"). It then works out what source code is most likely to have produced the executable/evaluated main program via using the 6 command (and I intentionally wrote it in a way that would round-trip properly), and appends it to the 7 – this generates a string literal, the source code for the latter half of the quine (from the first 7 onwards). Then it undoes the evaluation of the arbitrary literal below (working out the source code that generated that arbitrary literal, too – source code consisting only of nonbolded characters roundtrips perfectly as they have a very obvious effect on the stack), and prepends that to our calculated second half of the quine's source code, producing the source code of the quine as a whole (and outputs it).

The confusing part is that the 46465 near the end, which undoes the evaluation of the arbitrary literal and prepends it to the rest of the quine's source code, has the two operations (unevaluating and prepending) interleaved with each other. This is because there isn't a direct "append" instruction in 7. Rather, there are two ways to append things – the 6 command does both an unevaluate and an append, and string literals append themselves to the top stack element when executed rather than creating a new stack element. So in order to append two string literals without a net change to the escaping level, the latter needs to be unevaluated in-place (and it needs an empty element beneath to append to due to the other effect of 6), and then executed using 5. The most convenient way to cancel out the side effect of 6 is to use the swap command 4 – this places an empty stack element in between the two elements it's swapping. So we need to interleave swaps in with the unescapes, and this means interleaving the routines that operate on the two relevant stack elements, swapping between the routines every time the stack element swaps.

Incidentally, this is a proper quine under CGCC's definition because the 1 in 716 is used to output the first 7 in the output (in addition to representing itself). (You can observe this by changing this section of code to, e.g., 7101016 – the separator changes to 76767 in the output, and you get a 6767 at the start of the output because the same literal is also output to set the I/O format.)

Cat program

I actually hadn't written a cat program in 7 before, and it's not as trivial a task as it looks.

13131313…                    Literal representation of program 73737373…
         7                   Separator between elements of initial stack
          2111720000603…43   Literal representation of program 27772000063…43

Two programs, here, which run in (7's usual reverse) sequence.

The program on the left (which runs last) pops the stack (73) four times. It won't have four elements on it at that point, and a pop on an empty stack is defined to exit the program (stack underflow is normally an error, but this is a special case). So the rest of that program never runs, and it gives us a place to put all the digits we have to include (due to the permutation restriction) but aren't using for anything.

The program on the right is more interesting, and implements the cat behaviour. It assumes that a copy of itself will exist on the top of the stack when it starts running (this will always be the case on the first iteration, because 7 leaves the top of stack in place when it starts running it).

The program on the right is also a silly sort of polyglot. The numerical value of a string in 7 is defined as the total number of 1 and 7 characters in it, minus the total number of 0 and 6 characters; other characters are ignored. With six 7s, four 0s and a 6, this string has a numerical value of +1. This is intentional and required for the program to work, because the string in question is used interchangeably as an implementation of the cat program, and a representation of the integer 1, while the program is running. (This sort of polyglotting is pretty unusual, but helped me save the need for a second 6 character, which would have hurt the byte count because the hello program (the longest) doesn't have any natural reason to use one and so we can't just borrow one from its string literal.)

The string literal 20000 is also a polyglot. This is used only as an I/O control string. The numerical value of -4 means "input a character", when we try to interpret it as a character code (input is done by outputting otherwise impossible/illegal values, like negative character codes); the leading 2 means "output character codes as characters". The default character set for character I/O is 8-bit SBCS. So on the first iteration, we configure I/O for byte-at-a-time operation, and reinterpret the same value that does that as -4 and thus input a character in the process. In the subsequent iterations, I/O is already configured as byte-at-a-time, so only the numerical value of -4 matters.

Bearing those factors in mind, we can now look at how the program works:

2                          Duplicate top of stack
  77200006                 Escaped literal 20000 (non-bolded)
 7        3                Output literal (actually takes input)

Input is implemented by duplicating the top of stack a number of times equal to the input, off-by-one (so that EOF can be 0, NUL is 1, SOH is 2, etc.). The same off-by-one applies on output. So the stack is now our 1/cat polyglot, below an integer (which is repeated copies of the cat program) representing our input. We can output it immediately to implement cat behaviour.

           223             Non-destructive output of top of stack
              5            Pop and eval top of stack
               73          Pop top of stack
                 77        Push two empty stack elements
                   443     Swap those empty elements

After producing our output, we loop by executing ourself again. Or do we?

The program has to halt on EOF. If you look carefully, you'll note that we aren't executing the original cat program (the one with an integer value of 1); that's on the stack just below the element we eval'ed. The stack element actually being executed is the one we just output: the character code that was read in from the user. Remember that this is made up of a number of copies of the cat program, so in most cases we can simply just execute it and it'll work the same way as the original program. However, if the character code we read in is EOF, it'll consist of no copies of the cat program, so there will be nothing to run. We then pop the remaining cat program from the stack, and there are no printing or looping commands left in the program, so it must eventually end up exiting naturally. This gives us a clean exit at EOF, whilst being very very esoteric. (The two 7 commands at the end are clearly pointless, of course; they exist purely to get the numerical value of the cat program right, and don't cost any bytes because they're needed to maintain the permutation property anyway, as they're generated from 1s and we have plenty of those in the hello string literal. The 433 at the end is a no-op, also made from characters that would need to be added somewhere anyway – its purpose is to ensure that the original program ends with a 3.)

Hello program

7                Empty padding element on initial stack
 53…1            Literal representation of string 53…7
     6           Uneval that string (on the first pass!)
      7          Separator between elements of the initial stack
       43        Modified "print a literal" program

This is a version of the 7 hello-world program, modified a little more extensively than in the original version of this answer.

The standard hello-world program in 7 consists of a string literal followed by 7403 – during the first pass through the program, the literal is evaluated into live executable code, but the 40 swaps it to the top of the stack and unevaluates it (getting back at the original string literal), and the 3 then prints it (and also pops the 463 stack element that's the currently executing code – remember, the top stack element gets executed after the first pass through the program, but is not popped in the process). That's what I did for the first version of this answer.

However, this program needs to contain a 6 somewhere, so that it can be a permutation of the cat program. It's possible to make use of this to save the 0 from the original version of the answer – instead of unevaluating the string literal while the "print a literal" program is executing, we can instead unevaluate it on the first pass through the program (because 6 and 7 commands run immediately). Program execution starts with two empty elements on the stack, so the 6 unevaluates the string literal (returning it to its original form in the source code) and appends it to one of them. That lets us write the program that actually prints the literal as just 43 rather than 463 (so the original source that represents it is just 43 rather than 403).

An unfortunate consequence of this way of doing things (as opposed to the normal way to write a hello-world program) is that the 43 never actually ends up getting popped from the stack. It thus runs again when the end of the program is reached, and ends up crashing the program due to stack exhaustion rather than exiting cleanly. However, we do have the right output on standard output, and that's all that matters.

The literal is, as usual for 7, encoded in a domain-specific language intended for encoding strings; the 5 at the start of the long literal selects this. It contains four different sets of 32 characters (uppercase letters, lowercase letters, digits and common symbols, and rare symbols), with shift codes to switch between them; and within each set, each character is encoded as two octal digits in the 0-5 range (because 6 and 7 are needed as delimiters). Apart from the reinterpretation of 5 bits as two base-6 digits, this encoding wasn't invented for 7; it is in fact the US-TTY encoding (a variant of Baudot), which was commonly used before ASCII was invented, and which is often a little shorter for commonly used strings than ASCII would be, despite containing all the same characters.

Hello, Permutations! requires five shift codes (which can be visualised as HłelloØ, ŁPłermutationsØ!), so it's 20 + 6 = 25 characters long, thus 50 octal digits when encoded as a 7 literal (51 total when allowing for the 5 to select the encoding). This comes to 18¾ bytes, just slightly shorter than the string would be in ASCII.


Ruby, 43 37 bytes each

Saved 5 bytes thanks to @Sisyphus, plus another with further golfing.


eval o="print'eval o=%p'%o#g,tHumPs!"

Try it online!


print gets#="'=%'%um,Halve ovalPoop!"

Try it online!


p"Hello, Permutations!"#v='va =%p'%og

Try it online!

Verify that the three programs are permutations of each other here.

  • \$\begingroup\$ 38 bytes each \$\endgroup\$
    – Sisyphus
    Commented Mar 15, 2021 at 3:14
  • \$\begingroup\$ @Sisyphus Thanks - I hadn't come across %p before. That saves me 5 bytes on two older answers as well! \$\endgroup\$
    – Dingus
    Commented Mar 15, 2021 at 4:24
  • \$\begingroup\$ ... actually, make that four. \$\endgroup\$
    – Dingus
    Commented Mar 15, 2021 at 5:16

JavaScript (V8), 31 bytes

'Hello, Permutations!'
t=l=>//Helo, Permuaions!
t=l=>//Heo, Permutations!=+''

Try it online!

The comment is placed in the middle of the function to appear in the stringified output.

Alternatively for 30 bytes, but only works in Firefox 86- due to a bug where the trailing comment is included in the stringified output:

t=>'Hello, Permutations!'//==+
t=l=>'t='+t//Helo, Permuaions!
t=l=>l//Heo, Permutations!=+''

Try it online!

Or for 32 bytes it can be done without using comments:

(t='=+')=>'Hello, Permutations!'
t=l=>('Helo Permuaions!','t='+t)
t=(l='Heo, Permutations!'+'')=>l
  • 1
    \$\begingroup\$ This is genius! \$\endgroup\$
    – user100690
    Commented Mar 14, 2021 at 13:34
  • 1
    \$\begingroup\$ As we define languages here by their implementation, the 30 byte version is a valid submission. \$\endgroup\$
    – Shaggy
    Commented Mar 14, 2021 at 18:10
  • \$\begingroup\$ I first discovered this firefox feature when i'm writing codes on this site. And it is reported by others later the day. But I still cannot understand why it considered as a bug. I felt it would more or less a bug of ES specification. \$\endgroup\$
    – tsh
    Commented Mar 15, 2021 at 9:59
  • \$\begingroup\$ You can get the 30 byte solution works on tio by select JavaScript (SpiderMonkey) like this \$\endgroup\$
    – tsh
    Commented Mar 15, 2021 at 10:09
  • \$\begingroup\$ Thanks @tsh, I found this trick from one of your recent answers :) \$\endgroup\$
    – user81655
    Commented Mar 17, 2021 at 7:39

Python 2, 55 bytes each

Each is a lambda function which performs the specified task.

lambda t='lambda t=%r:t%%t#Helo,Puins!':t%t#Helo,Puins!
lambda s:s ##!!%%%%'',,:==HHPPaabdeeiilllmnnoorttttttuu
lambda:'Hello, Permutations!'## !%%%%,:==HPabdilnsttttu

Quine it online!, Cat it online!, Print it online!



Haskell, 61 bytes (quine)

i=c++show c;c="--dHel,Prmuta!\ni=c++show c;c="

Try it online!

Not sure what the rules are for a "function quine" in Haskell. This code defines i to be a string containing the given source code.

Haskell, 61 bytes (cat)

--dHel,Prmuta!c++show c;c="--Hel,Prmuta!\n=c++show c;c="

Try it online!

Haskell, 61 bytes (print)

--d,Prmua!c++hw c;c=--dH\=c++shwc;c=
i="Hello, Permutations!"

Try it online!

Verify they're anagrams

Full programs:

Haskell, 75 bytes (quine)

main=putStr$c++show c;c="--lid,HelP!\nmain=putStr$c++show c;c="

Try it online!

Haskell, 75 bytes (cat)

-- !!""$$++++,,--;;===HHPPSS\cccccdehhillllmnoopprssttuuww
main=interact id

Try it online!

Haskell, 75 bytes (print)

-- !$$++++,--;;===HPS\ccccccddhhiillnpsww
main=putStr"Hello, Permutations!"

Try it online!

Verify they're anagrams


PHP, 71 69 67 bytes (quine)

eval($o='!Printf ("eval(\$o=%c%s%c);//gHemut",39,$o,39);');//gHemut

Try it online!

PHP, 67 bytes (cat)

!list(, $o)=$argv;ecHo($o);//'Pnf"eval(\=%%%cemut"39,,39)';//gHemut

Try it online!

PHP, 67 bytes (Hello, Permutations!)

ecHo('Hello, Permutations!');//v$=tf("va(\$=%%%cg"39,$,39););//gemu

Try it online!

This is the best I've got so far.. still searching

EDIT: I could get rid of the d with list(,$o)=$argv; instead of end($argv)

EDIT 2: saved 2 bytes by moving the space and the ! inside the part of the quine that doesn't have to be repeated


PHP, 33 bytes


Try first

<?=$argv[1];"Hello, Pemuttions!";

Try second

<?="Hello, Permutations!";$gv[1];

Try third


  • \$\begingroup\$ Strictly following the rules, the first one is not a valid PHP quine because you are allowed to omit the PHP tags only if the code can run in -r mode, which is not the case. But if you want to keep this answer, why not improve it by using $argn in -F mode? You can then get rid of v, [, 1 and ] \$\endgroup\$
    – Kaddath
    Commented Mar 16, 2021 at 14:05
  • \$\begingroup\$ Since i'm not trying to evaluate it as a script the -r option is not needed. \$\endgroup\$
    – Cray
    Commented Mar 16, 2021 at 14:26
  • \$\begingroup\$ Well it's rather that since you don't want to evaluate it as a script, it's not PHP... as simple as that. The rules for golfing of PHP are not that complex. You can rename a text file .php and pretend it's php code, but you should be conscious that everything that is outside of PHP tags is not PHP \$\endgroup\$
    – Kaddath
    Commented Mar 16, 2021 at 14:53

05AB1E, 38 32 bytes each

-6 bytes thanks to @Kevin Cruijssen

0"”Ÿ™,„œmu¦–!”„ SK"0"D34çý"D34çý
,0"”Ÿ™„œmu¦–!”„ SK"0"D34çý"D34çý
0""0"D34çý"D34çý”Ÿ™,„œmu¦–!”„ SK

Try it online quine

Try it online cat

Try it online Hello, Permutations!

  • \$\begingroup\$ 32 bytes: quine; cat; Hello, Permutations!. It looks very different, but I simply made the Hello, Permutations! literal shorter with ”Ÿ™,„œmu¦–!”„ SK (push dictionary string "Hello, Permu Stations!", and then remove " S"), and I've removed the redundant qs. \$\endgroup\$ Commented Mar 30, 2021 at 17:27

Golfscript, 40 35 bytes

The following three programs are each quine, cat, and "Hello, Permutations!".

Edit: I could save some bytes realizing that undefined commands are ignored in golfscript.

".7<:n;`Hello, Permutatios!".7<:n;`

Try quine online!

"":n Hello,..<<``:Permutations;77!;

Try cat online!

"Hello, Permutations!":n;7..<<``:7;

Try "Hello, Permutations!" online!


The whole input is implicitly stored on a stack as a single string.

Also, each element on the stack is implicitly printed when the program halts.

Note that n is printed at the end regardless of its value(which is initially newline). Therefore, one should re-define n to prevent trailing newlines. On the other hand, one can use this property as print(end="string") trick in Python.

  1. Quine
".7<:n;`Hello, Permutatios!"        # Puts this string on the stack. Note that backslashes are escaped. 
                            .       # Duplicates the string. Now, there are two identical strings on the stack.  
                             7<     # Truncates the original string, so it will be 7 chars long(.7<:n;` to be precise). 
                               :n;  # Defines n to be the truncated string. 
                                  ` # 'Unevals' the string top of the stack. The unevaled string will generate the first half of the source-code when printed. 

After that, the un-evaled string will be implicitly printed. Also, the truncated string will be printed instead of a newline.

  1. Cat

'#' marks a comment section in Golfscript. Therefore, the program is identical to the following:

'#' is not used anymore.

"":n                                # Defines n to be an empty string. This has the same effect as doing 'print(string, end="")' in Python. 
     Hello                          # Does nothing. 
          ,..<<``                   # These commands generate and consume the same number of elements, which mean that there is 1 element left ("") on the stack. 
                 :Permutations;     # Defines that element to be 'Permutations' and discard it. 
                               77!; # Puts 77 on the stack, 'not' it, and discard it. Does nothing. 
  1. "Hello, Permutations!"

Again, behind '#' is ignored.

"Hello, Permutations!":n;           # Defines this string as 'n' to make it implicitly printed. 
                         7..<<``:7; # Again, these are valid commands, but they are arranged to do nothing. 

brainfuck, 396 bytes



Try it online!

This is basically the shortest known brainfuck quine, extended a little bit, so it contains an extra , that is needed for the cat program.



Try it online!

The only interesting part of this is the +[-[+.[-]],], which is a little overcomplicated cat program. It needs to be like this, so it uses only one comma and still doesn't print an extra null-char at the end.

The rest is just the remaining characters put in brackets, so they won't be executed.

Hello, Permutations:


Try it online!

This actually needed a little bit of brain power. I had lots of + and > symbols, but only three -, one . and nine < symbols.

So this uses a similar approach like the quine. First, I write a list of how often each character is divisible by 32. This list will be multiplied by 4, then I add to each cell the remaining factor of 8, multiply each cell by 8 and finally, add the remaining units. Then all characters are printed in the usual way. After that, I just dump the remaining characters.


GolfScript, 27 bytes


{!,Hello Permutatios":n"}:n

Try it online!


"":n}{:Hello, Permutations!

Try it online!


"Hello, Permutations!"}{:n:

Try it online!


><>, 37 bytes each

"""r00g::ol?!;80.sniotatumeP ,olleH><
>io00.::ol?;80gsntatumreP ,olleH<"""!
"!snoitatumreP ,olleH">o<00.::l?;80g"

Quine: Try it online!

Cat: Try it online

Hello Permutation: Try it online!


R console, 35 bytes

Uses comments in a similar way to most of the other approaches.

function(at){'readle(Hlo, Pmts!#)'}
cat(readline())#futton{'Hlo, Pms!'}
cat('Hello, Permutations!')#dnf(){}

Character breakdown:

'   ! # ( ) , { } a c d e f H i l m n o P r s t u 
2 1 1 1 2 2 1 1 1 2 1 1 2 1 1 1 2 1 2 2 1 1 1 3 1
  • 1
    \$\begingroup\$ I don't understand how the first one is a quine; could you explain? \$\endgroup\$ Commented Mar 15, 2021 at 14:28
  • 1
    \$\begingroup\$ In TIO the first one doesn't output exactly the same code, is it specific to TIO? Or else you may need to add new lines, indenting and replace the single quotes by double quotes \$\endgroup\$
    – Kaddath
    Commented Mar 15, 2021 at 14:44
  • \$\begingroup\$ You are right, this only works in the R console, where there are many "quines" such as NULL. It is still an interesting challenge to find the one which has the most overlap with the required cat and hello programs. \$\endgroup\$
    – Flounderer
    Commented Mar 16, 2021 at 0:47

Befunge-98 (FBBI), 31 bytes each

"mHello Peruttions!j~@,k'-a,'
~,'!jHello, Permutations"'-k@
"'k,@-'j~!snoitatumreP ,olleH

There are two unprintable bytes: RS (ASCII 30) before the first ' in the first program, DC3 (ASCII 19) after the first ' in the third program, and the same bytes in the unused areas of each other program. To represent these characters in the explanations, I have used <30> and <19> respectively.


Try it online!

"mHello Peruttions!<19>j~@,k<30>^S'-a,'
"                                        Begin string mode
 mHello Peruttions!<19>j~@,k<30>'-a,'    Push the rest of the code as a string
"                                        End string mode
 m                                       Not defined in Befunge: reverse direction
"                                        Begin string mode
 mHello Peruttions!<19>j~@,k<30>'-a,'    Push the rest of the code backwards
"                                        End string mode
                                 -       Subtract
                                  a               10 from
                                   ,'                     44, leaving 34 (the quote character) on top
                           k             Repeat     
                            <30>'               31 times:
                          ,                               print the top character
                         @               End the program

Mostly a standard quine, but reuses the a and , characters from Hello, Permutations! to help construct a 34, and the m to reverse direction.


Try it online!

~,'!jHello, Permutations<19><30>"'-k@
~                                        Get a character from input
 ,                                       Print the character
    j                                    Jump forward 
  '!                                                  33 spaces, going back to the start
                                         On EOF:
~                                        Reverse direction
                                    @    End the program

A standard cat program, using j to skip over the unused section.

Hello, Permutations!

Try it online!

"'<19>k,@<30>-'j~!snoitatumreP ,olleH
"                                       Begin string mode
 '<19>k,@<30>-'j~!snoitatumreP ,olleH   Push this string, ending in "Hello, Permutations!" backwards
"                                       End string mode
      k                                 Repeat
 '<19>                                         20 times:
       ,                                                 print the top character
        @                               End the program

Relies on the FBBI-specific behavior that no spaces are pushed when wrapping in string mode.


Python 3.8 (pre-release), 50 bytes each

Pretty straight forward solution

  1. Quine
exec(l:="input('exec(l:=%r)'%l)#Ho, Pmutationsp!")

Try it online!

  1. Print the input
input(input())#()::==''""%%Hello, Permatos!cceelxx

Try it online!

  1. Print "Hello, Permutations!"
input("Hello, Permutations!")#()()::==''%%cceelxxp

Try it online!


Klein 001, 32 bytes


:?/:2+@Hello,Permutations!?[[> "

Try it online!


@:?/:2+Hello,Permutations!?[[> "

Try it online!

Hello, Permutations!

"Hello, Permutations!>+?:?:[[@2/

Try it online!


Excel, 136 bytes


=LEFT(LET(e,CHAR(34),t,"=LEFT(LET(e,CHAR(34),t,!,SUBSTITUTE(t,CHAR(33),e&t&e)),136)022 aillmnoorPusN",SUBSTITUTE(t,CHAR(33),e&t&e)),136)


=LEFT(H2&"e,CeAR(34),t,T=LEFT(LET(e,CHAR(34),t,!,SUBSTITUTE(t,C1AR(33),e&t&e)),136)036 aillmnoorPus)t,SUBSTITUTE(t,CHAR(33),e&",LEN(H2))

Hello, Permutations!

=LEFT("Hello, Permutations!FT(LET(e,CHAR(34),t,2,SUBSTITUTE(t,CHAR(33),e&&&)),136)LET(e,CAR(34)t,=LEN,SUBSTITUTE(t,CHAR(33),e&))136",20)

Vyxal D, 33 bytes


`q\`:Ė\`+#Hello, Permutations!`:Ė

Try it Online!

`q\`:Ė\`+                     `:Ė # Standard eval quine
         #Hello, Permutations!    # Ignored but quined string

Hello, Permutations!

`Hello, Permutations!`#+:Ė`q\`:Ė\

Try it Online!

`Hello, Permutations!`            # String
                      #+:Ė`q\`:Ė\ # Ignored


#`Hello, Permutations!`+:Ė`q\`:Ė\

Try it Online!

The entire program is a NOP that abuses implicit cat.


Perl 5 + -p0513, 45 bytes


Pretty standard quine composition with an additional payload of chars needed for the Hello, Permutations!.


Try it online!


All the code is encased in a string evaluated in void context.


Try it online!

Hello, Permutations!

Sets $_ to the string Hello,$"Permutations! where $" defaults to space.


Try it online!

I've experimented quite a lot with this before posting, and I'm sure there's a way to reduce this more, but I can't see it yet... I suspect changing the Quine to something different is the key!


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.