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
Derp
you must output
[0, 1, 2, 3]
(or some equivalent). This is because D
is in the 0
th position, e
is in the 1
st, r the 2
nd, and p
the 3
rd.
Let's take another program which is the original program, but with its characters permuted:
epDr
You must output
[1, 3, 0, 2]
because e
is in the 1
st position of the original program, p
is in the 3
rd position, D
the 0
th, and r
the 2
nd.
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)
Rules:
- 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 0 1 2 3
12
in R be valid? It would simply print12
and if permuted;21
. \$\endgroup\$