# Decipher the language

An alien planet called EMJ-26 has an alphabet that has letters switched around. Their language is identical to english but they use different letters. Here are the names of some countries on earth written in their language:

QAREZSTZQ
WVTZQ
CQOQZ
UEFTWI
NCOMIKST
PQSQA
MISLJQZQ
DEZEGKEXQ
SKZTLTQ
YHARHGLSQZ
BTCT
XQIL

Can you decipher their language?

The country names are (in order)

ARGENTINA, CHINA, JAPAN, MEXICO, DJIBOUTI, QATAR, BOTSWANA, VENEZUELA, TUNISIA, KYRGYZSTAN, FIJI, LAOS

With the following identification of letters

Each letter in the first row is deciphered to the corresponding letter below it in the second row


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
R F J V E X Z Y O W U S B D P Q A G T I M H C L K N


How to figure this out

If we look at YHARHGLSQZ first, the second and fifth letters are the same.
As far as I'm aware, the only ten letter country name with this property is KYRGYZSTAN so this already gives us the mappings for A, G, H, L, Q, R, S, Y, Z. Then the first country must be ARG_NT_NA, which must be ARGENTINA so we additionally get mappings for E and T.
The second country then becomes __INA which must be CHINA so we get W and V. The third country becomes _A_AN which must be JAPAN so we get C and O. After that it's not too difficult to fill in the gaps for the rest of the countries.

• I'm rather at a loss to see what more explanation can be given than the correspondence between letters that hexomino's already given. Unless you're saying that there's some pattern to which letters are replaced with which, which you wanted to be found? Commented Nov 27, 2020 at 13:50
• @GarethMcCaughan: I thought it was pretty standard on this site to say not just what the answer is but also how you got there... The post has since been edited to include this but I'm mildly surprised that this was a confusing request for you... Commented Nov 27, 2020 at 14:18
• It's pretty standard to give some explanations. But e.g. if you're doing a cryptic crossword you're expected to explain how to parse the clues, not your thought processes in working out how to parse them. Simple substitution ciphers are pretty easy to solve in many ways. You can e.g. literally solve this one by copying-and-pasting into the box on quipqiup.com, though some would regard that as cheating :-). Or by counting frequencies, comparing against the corresponding list for countries, and trying a couple of possibilities. Or by looking at (say) the first word's pattern of letters and ... Commented Nov 27, 2020 at 22:03
• ... searching a list of countries for any with the same pattern of letters. I mean, obviously one can do any of those things and say one did, and as it happens hexomino seems to have taken quite a methodical path, but if the answer is "Far the commonest country-name letter is A and far the commonest letter in here is Q, and now I just looked at all the countries whose names were A.......A to see if any had the right pattern" or something, does it really need that level of explanation? I dunno, maybe it does. It just didn't seem to me like the sort of puzzle for which ... Commented Nov 27, 2020 at 22:06
• ... that level of detail is necessary. Commented Nov 27, 2020 at 22:06

To continue from @hexomino's excellent answer:

The substitution is derived from...

The keyboard alphabet QWERTYUIOPASDFGHJKLZXCVBNM.
First, take @hexomino's deciphering key and rewrite it as an enciphering key:

Plain:   ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher:  QMWNEBRVTCYXUZIOPALSKDJFHG

Notice that every second letter of the key spells out QWERTY. I think the key was derived by writing the letters of the keyboard alphabet below every other letter of the standard alphabet, and then reversing direction to write the remaining letters after reaching the end. I don't see how to explain the IOPA, though.

Plain:   ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher:  Q.W.E.R.T.Y.U.IOPA.S.D.F.G
Cipher:  .M.N.B.V.C.X.Z....L.K.J.H.

I think I can do better. Let me imagine how the aliens' keyboards must look:

ACEGIKMOPQ
RTVXZYWUS
NLJHFDB

This is the alien keyboard layout. The alien's keys are labeled like this, but the computer thinks the keyboard is a U.S. keyboard. When the alien presses A, a Q comes out on the screen. So pressing the keys labeled ARGENTINA will type out QAREZSTZQ. Now, how was this alien keyboard layout derived?
The first letter A was written on the first key of the first row. The second letter B on the last key of the last row. Then, C in the second key of the first row, and D in the second-to-last key of the last row. After the last row is full, the letters OPQ cannot alternate between the first and last row so they fill the remainder of the first row. Finally, the letters R through Z alternate between the two ends of the middle row.

A.........
.........
......B

aC........
.........
.....Db

acegikmOPQ
.........
nljhfdb

acegikmopq
R.......S
nljhfdb