Determine the lexicographical permutation your code is in

Write a program that outputs the number 0.

That's a bit trivial, isn't it?

Let's sort all distinct permutations of your code in lexicographical order. When any of these codes are run, it should output the its location in the array (0-indexed or 1-indexed).

This means that your code must be the lexicographically smallest permutation of your code possible.

For example, if your code is ABB, then ABB -> 0; BAB -> 1; BBA -> 2.

Rules

• Out of all distinct permutations of your code, it must be the lexicographically smallest.
• Your program must be at least 3 bytes long.
• "Output" represents any acceptable output: on the stack, to STDOUT, as a return value, as an exit code, etc.
• Your program is to not take any form of input.
• This is , so longest code wins.
• This seems really, really hard :) – Jonah Apr 28 at 12:57
• I think the score should be the number of distinct permutations, not the length. – isaacg Apr 28 at 15:32
• It would be a good idea if you sandboxed your challenges instead of posting them right away... It would help you trim down the rough ends and help you create really neat challenges. – RGS Apr 28 at 15:36
• This really should have also had an irreducibility requirement added. That way, infinite answers would be so trivial. – Lyxal Apr 29 at 7:13
• I’m voting to close this question because it's too easy to get an infinitely large score, leaving the challenge effectively without an objective winning criterion. – pppery Jun 16 at 19:17

brainfuck, bytes = score

...


Try it online!

How it works: this program only has one distinct permutation and it outputs 0. It trivially satisfies all the other restrictions. The score can be made arbitrarily large by adding more ..

• Can be extended indefinitely to be made arbitrarily large! Highly recommend adding ∞ bytes. Also, perhaps clarifying that it outputs ascii(0), rather than a literal 0. Want to let you do as you see fit with it, but if you don't see this, I'll gladly make the edit for you! Unless, others chime in and think it a bad idea, but it seems to me fair game as it's still in the spirit of your answer! – AviFS Apr 29 at 2:36

Python 2, score = arbitrary

000


Try it online!

Returns through exit code, which is always 0.
The source code is 0 repeated arbitrary many times. Since there's only 1 permutation of the source code, the permutation number is always 0.

!@#\$%^&*()_+, 548+++ bytes

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Try it online!

This can also be just#^^. # prints and ^ increments. Please tell me if this is not lexicographic order, instead of downvoting.

• Since this is infinitely expandable, you could just say "infinite" bytes. – user92069 Apr 30 at 2:03
• Good job for having multiple distinct characters! – isaacg Apr 30 at 10:13
• this might work in other stacked languages using many increments and one output – Wezl Apr 30 at 15:09

dc, Arbitrarily large number of bytes.

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000


Try it online!

No matter how many 0s you write, it will leave a 0 on the stack, which is an acceptable output form for the challenge. (The p in the TIO footer prints the stack so you can see what it is.)

Of course, the only permutation is the program itself.

MathGolf, 3 bytes (3 distinct permutations)

Outputs via unary, with a different set of output: 2 -> 3 -> 4.

00\


Try it online!

Explanation

00\
00  Push 2 0's
\ Swap (resuting in 2 0's)

0\0
0   Push 0
\  Swap
0 Push 0 (3 0's)

\00
\   Swap the empty stack (appends 2 0's)
0  Push 0
0 Push another 0 (resulting in 4 0's)

• Uhh, I can't seem to find a permutation that outputs 6 zeroes. – the default. Apr 28 at 13:38
• @mypronounismonicareinstate What about now? It seems that equivalent permutations are considered the same this time. – user92069 Apr 29 at 6:25