2
$\begingroup$

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

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

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – klm123 Jun 17 '14 at 13:56
  • $\begingroup$ I have to agree with klm123; you don't appear to be providing much detail here, and it's not much to work with. $\endgroup$ – Joe Z. Jun 17 '14 at 14:31
  • 1
    $\begingroup$ 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. $\endgroup$ – r.s Jun 17 '14 at 14:37
  • 10
    $\begingroup$ Occam's razor: the word for "LIOQWERRPOIL" is "PJIUAZAKLKP". The word for any given input is "PJIUAZAKLKP". $\endgroup$ – Kevin Jun 17 '14 at 17:00
  • 2
    $\begingroup$ 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." $\endgroup$ – Cruncher Jun 17 '14 at 20:04
5
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Thank you.. Yes as you said it should be good. $\endgroup$ – r.s Jun 17 '14 at 14:14
4
$\begingroup$

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

$\endgroup$
3
$\begingroup$

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.

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

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
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.