If COMPUTER is coded as DPNQVUFS, how is SYSTEM coded in the same language?
TZTUFN. Each letter of COMPUTER is shifted one place forward (C to D, O to P, and so on), so SYSTEM becomes T, Z, T, U, F, N.
Explain it simply
Most letter-coding questions apply one simple rule to every letter: shift forward or backward by a fixed amount, reverse the word, or replace each letter by its opposite in the alphabet. Write the original and the code one above the other, check the shift for two or three letters, and only then apply it.
Example
Question: COMPUTER = DPNQVUFS. Code SYSTEM.
- Compare: C to D (+1), O to P (+1), M to N (+1), P to Q (+1). The rule is +1 for every letter.
- Apply to SYSTEM: S to T, Y to Z, S to T, T to U, E to F, M to N.
- Code = TZTUFN.
A different common rule is the "opposite letter" code, where A pairs with Z, B with Y and so on (position p becomes 27 - p). Under that rule ROSE becomes ILHV: R (18) to I (9), O (15) to L (12), S (19) to H (8), E (5) to V (22).
const shift = (w, k) => [...w].map(c => String.fromCharCode(((c.charCodeAt(0) - 65 + k + 26) % 26) + 65)).join("");
const opposite = w => [...w].map(c => String.fromCharCode(155 - c.charCodeAt(0))).join("");
console.log(shift("SYSTEM", 1)); // Output: TZTUFN
console.log(opposite("ROSE")); // Output: ILHVWhat to say in the interview
"Comparing letter by letter, every letter moves one step forward. Applying that to SYSTEM gives TZTUFN. I always check at least three letters before trusting the rule."
Common mistakes
- Assuming the shift from the first letter only, when some codes use alternating shifts like +1, -1.
- Forgetting to wrap from Z back to A.