General Aptitude

Coding-decoding and odd one out

Part 1 of 2 · 14 min

Coding and decoding

The concept

Start with something familiar

As kids, many of us passed secret notes in class: "IFMMP" for "HELLO", each letter moved one step along the alphabet. Anyone who knew the rule could read it. Anyone who didn't saw nonsense.
Coding-decoding questions give you one word and its code, and ask you to find the rule and apply it to another word. The rule is almost always one of a handful of patterns. Your job is to test the right patterns quickly, and to check the rule on every letter before you trust it.

Idea 1: turn letters into numbers, A = 1 to Z = 26

Every pattern is easier to see with numbers. Learn the positions, using the anchor word EJOTY: E, J, O, T and Y sit at 5, 10, 15, 20 and 25. Any other letter is a step or two from one of them.
AnchorPositionOppositePosition
E5V22
J10Q17
O15L12
T20G7
Y25B2
The opposite letter counts from the other end: A pairs with Z, B with Y, and so on. Opposite letters always add up to 27:Opposite position=27−position\text{Opposite position} = 27 - \text{position}
Key idea
A = 1 to Z = 26, anchored by EJOTY (5, 10, 15, 20, 25). A letter and its opposite add to 27.
Example
What are the position and the opposite of R?
R is 3 after O (15), so R is 18. Its opposite is 27−18=927 - 18 = 9, which is I.

Idea 2: a constant shift moves every letter by the same number

The simplest code adds the same number kk to every letter's position. When you pass Z, wrap round to A, just like a clock passes 12.Code letter=letter+k\text{Code letter} = \text{letter} + kRemember to wrap after Z.
Example
If CAT is coded as ECV, how is DOG coded?
C to E is +2+2, A to C is +2+2, T to V is +2+2. The shift is +2+2 for every letter. DOG becomes FQI.
Example
Code ZEBRA with a shift of +3.
Z +3+3 wraps round: Z, A, B, C, so Z becomes C. Then E to H, B to E, R to U, A to D. ZEBRA is CHEUD.

Idea 3: the shift can change from letter to letter

If the first letter moves by +1+1 and the second doesn't, the shift isn't constant. Write the shift for each position and look for a pattern in those shifts:
PatternShiftsExample
Growing+1,+2,+3,+4+1, +2, +3, +4GATE to HCWI
Alternating+1,−1,+1,−1+1, -1, +1, -1TIGER to UHHDS
Constant+3,+3,+3+3, +3, +3MANGO to PDQJR
Example
If GATE is coded HCWI, how is EXAM coded?
G to H is +1+1, A to C is +2+2, T to W is +3+3, E to I is +4+4. Apply +1,+2,+3,+4+1, +2, +3, +4 to EXAM: E to F, X to Z, A to D, M to Q. EXAM is FZDQ.

Idea 4: opposite letters and reversed words are two more standard codes

Two codes don't shift at all:
  • Opposite letters: each letter becomes its partner from the other end (Idea 1). GATE becomes TZGV, because G and T, A and Z, T and G, E and V are opposite pairs.
  • Reversed order: the word is written backwards, often combined with a shift.
A quick test for opposite coding: the letter and its code should add up to 27.
Example
In a code, FRIEND is written EOFJSG. What's the rule?
The shifts F to E (−1-1), R to O (−3-3) look random. Try reversing FRIEND: DNEIRF. Now D to E, N to O, E to F, I to J, R to S, F to G: all +1+1. The rule is reverse, then shift by +1.

Idea 5: in number codes, a word's number usually comes from its letter positions

When a word is coded as a single number, try the sum of positions first, then the sum of opposite positions:Sum code=∑positionsOpposite sum=27×n−sum\begin{aligned} \text{Sum code} &= \sum \text{positions} \\ \text{Opposite sum} &= 27 \times n - \text{sum} \end{aligned}Here nn is the number of letters.
Example
If CAT = 24, what is DOG?
C+A+T=3+1+20=24C + A + T = 3 + 1 + 20 = 24, so the code is the sum of positions. DOG =4+15+7== 4 + 15 + 7 = 26.

How to spot which idea you need

The question says...Use
any letter codeIdea 1: write positions
every letter moves the sameIdea 2: constant shift, wrap after Z
shifts differ by positionIdea 3: pattern in the shifts
shifts look randomIdea 4: opposite pairs or reversed word
a word equals a numberIdea 5: sum or opposite sum

Worked example 1warm-up

In a code, PAPER is written as QBQFS. How is PENCIL written in that code?
Solution
Step 1. Positions and shiftsIdeas 1 and 2
P to Q, A to B, P to Q, E to F, R to S: every shift is +1+1.
Step 2. Apply to PENCILIdea 2
P to Q, E to F, N to O, C to D, I to J, L to M.
Step 3. Answer
QFODJM.
Step 4. Check
Every letter of PENCIL moved exactly one step, the same as every letter of PAPER.

Worked example 2GATE level

In a code, FRIEND is written as EOFJSG. How is CANDLE written in that code?
Solution
Step 1. Try a direct shiftIdeas 2 and 3
F to E is −1-1, R to O is −3-3, I to F is −3-3. Not constant and no clear pattern.
Step 2. Try reversingIdea 4
FRIEND backwards is DNEIRF. Compare with EOFJSG: every letter moves +1+1.
Step 3. Apply to CANDLEIdeas 4 and 2
Reverse: ELDNAC. Shift each by +1+1: E to F, L to M, D to E, N to O, A to B, C to D.
Step 4. Answer and check
FMEOBD. Check with FRIEND: reversing and shifting gives E, O, F, J, S, G, exactly the given code. (Shifting CANDLE without reversing gives DBOEMF, a likely trap option.)

All the rules at a glance

IdeaRule
PositionsEJOTY = 5, 10, 15, 20, 25
Oppositesposition ++ opposite =27= 27
Constant shiftsame +k+k for all, wrap after Z
Changing shiftread the shifts as a series
Reversewrite backwards, then test shifts
Number codessum, or 27n−27n - sum