Positional Awareness

Your task is to generate a program that, for every permutation of its characters (which includes the original program), outputs the positions of every character relative to the original program.

If your program is


you must output

[0, 1, 2, 3]

(or some equivalent). This is because D is in the 0th position, e is in the 1st, r the 2nd, and p the 3rd.

Let's take another program which is the original program, but with its characters permuted:


You must output

[1, 3, 0, 2]

because e is in the 1st position of the original program, p is in the 3rd position, D the 0th, and r the 2nd.

If the original program has two repeating characters:

abcda -> [0, 1, 2, 3, 4]

Then for the permutation, the 0 and the 4 in the array must be in ascending order:

baadc -> [1, 0, 4, 3, 2] (0 first, then 4)


  • Your program must contain at least two unique characters.
  • At most floor(n/2) characters are to be the same.

     aabb (acceptable)
     aaaabc (not acceptable, only floor(6/2) = 3 a's allowed)
  • Your program's output can be either an array (or something similar) containing all the characters' positions in order, or a string with any delimiter, so these are perfectly fine:

    [0, 1, 2, 3]
    0 1 2 3
  • 7
    \$\begingroup\$ I don't believe this challenge allows for any non-trivial solution as virtually any answer in any language of length >= ~5 will not be a valid program for every permutation, let alone a program that solves the challenge at hand. \$\endgroup\$
    – orlp
    Dec 21, 2016 at 5:32
  • 1
    \$\begingroup\$ @Qwerp-Derp Almost nobody says anything on the sandbox. A while ago, I've posted a question after being in the sandbox for around a month (or so). And only when I've posted it, was when people pointed out mistakes and the downvotes rained. In my honest opinion, the sandbox is useless. \$\endgroup\$ Dec 21, 2016 at 10:33
  • 1
    \$\begingroup\$ For once, I feel like in this challenge, a longer answer would be more impressive than a shorter one. \$\endgroup\$
    – Wojowu
    Dec 21, 2016 at 13:05
  • 1
    \$\begingroup\$ @Wojowu I can make it code-bowling, if that's possible - the longest program wins. \$\endgroup\$
    – clismique
    Dec 21, 2016 at 14:02
  • 1
    \$\begingroup\$ Would the program 12 in R be valid? It would simply print 12 and if permuted; 21. \$\endgroup\$
    – Billywob
    Dec 21, 2016 at 14:48

2 Answers 2


Actually, 2 bytes


Try it online!

This prints


while the (only) other permutation




How it works

In Actually, consecutive digits are parsed separately, so 10 pushes 1 on the stack, then 0 on top of it.

When the program finishes, the stack is printed top to bottom, so it prints 0 first, then a linefeed, then 1.

The derranged program 01 does the same, in the opposite order.

  • 1
    \$\begingroup\$ Other languages this works in; Seriously, 05ab1e, ///, 2sable. \$\endgroup\$ Dec 21, 2016 at 11:30
  • \$\begingroup\$ The spec says the numbers have to be separated. It does work in Seriously, but Actually is actually just Seriously 2.0. \$\endgroup\$
    – Dennis
    Dec 21, 2016 at 11:32

Jelly, 2 bytes


Try it online!

Outputs: [0, 1]

Other permutation J; outputs: [1, 0]

How it works:

;          Concats 0 with...
 J         [1...len(z)], here just [1]

J          [1...len(z)], here just [1]
 ;         ...Concatted with 0

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.