# character decoding problem at an interview [closed]

If "PSAKLJIUASP" is "PJIUAZAKLKP" then, what is the word for "LIOQWERRPOIL"?

I noticed that first 3 characters are reverse of last 3 characters in both words in question. A is mapped to I and I is mapped to A. But same logic don't work for other cases. Any clues please?

-

## closed as too broad by leoll2, mdc32, A E, Mike Earnest, michaelpriApr 20 '15 at 3:09

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Have you got any additional information about how this phrase was obtained? Like, that any letter in encoded phrase must correspond to one and only one letter in decoded phrase. – klm123 Jun 17 '14 at 13:56
I have to agree with klm123; you don't appear to be providing much detail here, and it's not much to work with. – Joe Z. Jun 17 '14 at 14:31
I admit. Sorry i don't have any further information. I tried to solve but its not ending up anywhere. So thought community can shed some light. – SandyR Jun 17 '14 at 14:37
Occam's razor: the word for "LIOQWERRPOIL" is "PJIUAZAKLKP". The word for any given input is "PJIUAZAKLKP". – Kevin Jun 17 '14 at 17:00
In an interview I would say: "I'm sorry there's not enough information to answer the question. There are many possible mappings. I could provide you one that works, but it likely isn't the one you're looking for." – Cruncher Jun 17 '14 at 20:04

I don't see a nice answer, but there are some things you should notice. First, the wording is ambiguous: We are told "PSAKLJIUASP" is "PJIUAZAKLKP", but it is not clear whether "LIOQWERRPOIL" should be the source or destination. I would notice the groups of three letters AKL and JIU which are maintained but shifted in position. Unfortunately that leaves (besides the leading and trailing P's) S and AS, which might go to K and AZ, but it is not clear how. If "LIOQWERRPOIL" is the source, that leads us to "LERR??OQW?L"

For an interview question, I would think this is coherent enough to show I wasn't flustered by nonsense and try to go on.

-
Thank you.. Yes as you said it should be good. – SandyR Jun 17 '14 at 14:14

If you assign a value to each letter (a = 1, b = 2... z = 26) and add up each letter, the two sample words "PSAKLJIUASP" and "PJIUAZAKLKP" are both equal (137).

The test word adds up to 169, so it seems like any 12 character word with the same value should suffice (my favorite so far has been "zzzsoeeaaasy").

-

I suspect these words are deliberate gibberish.

The only letters in these words are A E I J K L O P Q R S U W and Z. Look at the positions of these letters on the keyboard:

[Q][W][E][R] T  Y [U][I][O][P]

[A][S] D  F  G  H [J][K][L]

[Z] X  C  V  B  N  M


This looks rather like the sort of distribution you would produce if you were mashing the keyboard randomly with both hands.

-
When I looked at this question too I wondered about keyboards - does the OP come from a bilingual country with two different keyboard setups? – Ken Y-N Aug 29 '14 at 4:32

There are many possibilities. The first that cam to mind was to preserve the first and last characters and pick random values for the rest but that seemed a bit silly. So here is something a little more sensible.

function conv(A,a,b){
for(var B='', i=0; i<A.length; i++){
var d=a.charCodeAt(i%a.length)-b.charCodeAt(i%b.length);
B+=String.fromCharCode( d+A.charCodeAt(i));
}
return B;
}


The function take a pattern to be converted $A$ and two sample patterns $a$ and $b$. It calculates the difference in ASCII values of pairs of sample characters and apply it to characters of the pattern to be converted. In cases such as the example where the pattern to convert is longer than the sample it returns to beginning of the sample for more characters.

The result looks a bit of a mess and highlights the problems that may occur with this method.

LRGGb5Z\EWIL

-