If DELHI is coded as 73541 and CALCUTTA as 82589662, how is CALICUT coded?
8251896. Each letter has a fixed digit: D 7, E 3, L 5, H 4, I 1, C 8, A 2, U 9, T 6. So C-A-L-I-C-U-T becomes 8-2-5-1-8-9-6.
Explain it simply
Here there is no arithmetic rule; each letter simply stands for a digit, like a substitution table. Build the table from the given words, checking that a repeated letter always gets the same digit (both C's in CALCUTTA are 8, both T's are 6). Then read off the new word.
Example
Question: DELHI = 73541, CALCUTTA = 82589662. Code CALICUT.
- From DELHI: D 7, E 3, L 5, H 4, I 1.
- From CALCUTTA: C 8, A 2, L 5, C 8, U 9, T 6, T 6, A 2. (L = 5 again, which confirms the mapping is consistent.)
- CALICUT: C 8, A 2, L 5, I 1, C 8, U 9, T 6.
- Code = 8251896.
const map = {};
const learn = (w, c) => [...w].forEach((ch, i) => (map[ch] = c[i]));
learn("DELHI", "73541");
learn("CALCUTTA", "82589662");
console.log([..."CALICUT"].map(ch => map[ch]).join("")); // Output: 8251896What to say in the interview
"It's a direct substitution, so I build a letter-to-digit table from both words, checking that repeated letters agree. Reading CALICUT through the table gives 8251896."
Common mistakes
- Looking for a numeric shift (like position values) when the mapping is arbitrary.
- Missing that I comes from DELHI, not CALCUTTA.