3
\$\begingroup\$

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.
\$\endgroup\$
13
  • 4
    \$\begingroup\$ This seems really, really hard :) \$\endgroup\$
    – Jonah
    Commented Apr 28, 2020 at 12:57
  • 17
    \$\begingroup\$ I think the score should be the number of distinct permutations, not the length. \$\endgroup\$
    – isaacg
    Commented Apr 28, 2020 at 15:32
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – RGS
    Commented Apr 28, 2020 at 15:36
  • 2
    \$\begingroup\$ This really should have also had an irreducibility requirement added. That way, infinite answers would be so trivial. \$\endgroup\$
    – lyxal
    Commented Apr 29, 2020 at 7:13
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jun 16, 2020 at 19:17

5 Answers 5

6
\$\begingroup\$

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

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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! \$\endgroup\$
    – AviFS
    Commented Apr 29, 2020 at 2:36
5
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

!@#$%^&*()_+, 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.

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

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.

\$\endgroup\$
1
\$\begingroup\$

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)
\$\endgroup\$
2
  • \$\begingroup\$ Uhh, I can't seem to find a permutation that outputs 6 zeroes. \$\endgroup\$ Commented Apr 28, 2020 at 13:38
  • \$\begingroup\$ @mypronounismonicareinstate What about now? It seems that equivalent permutations are considered the same this time. \$\endgroup\$
    – user92069
    Commented Apr 29, 2020 at 6:25

Your Answer

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