10
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
7I 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. – orlp – 2016-12-21T05:32:01.683
@orlp What if I reduce it to one permutation? This didn't come up in the sandbox at all, so I didn't realise the problem. I expected this challenge would be like the "Hyperprogramming" one (which was possible), but I guess I'm wrong. – clismique – 2016-12-21T05:35:09.583
1@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. – Ismael Miguel – 2016-12-21T10:33:46.080
1For once, I feel like in this challenge, a longer answer would be more impressive than a shorter one. – Wojowu – 2016-12-21T13:05:24.553
1@Wojowu I can make it [tag:code-bowling], if that's possible - the longest program wins. – clismique – 2016-12-21T14:02:10.303
1Would the program
12
in R be valid? It would simply print12
and if permuted;21
. – Billywob – 2016-12-21T14:48:43.523@JamesHolderness I think this might warrant a new question, perhaps with a different criterion than this one. I'll come up with something. – clismique – 2016-12-22T12:11:43.260