Coding-Decoding
Mental model
Every letter is a number in disguise.
Alphabet characters operate on a fixed mathematical ring (1 to 26). Visualizing them as numbers reveals the mathematical operations (+1, -2, reverse) hiding behind random letters.
Method
- Write the alphabet and assign numerical positional values (A=1...Z=26). Keep reverse mappings (A=26...Z=1) handy.
- Write the original word and its coded version stacked directly underneath each other. This visualizes vertical alignment.
- Check for direct letter shifting. Calculate the numerical difference between the stacked letters (+1, -2, +3, etc.).
- If vertical shifts don't make a pattern, check for cross-patterns (first letter codes to last letter) or halves-reversal (split word in half and reverse each).
- Once the exact mathematical or positional rule is confirmed on the example, apply it strictly to the target word.
Worked example
Problem: In a certain code language, 'WATER' is coded as 'YCVGT'. How will 'FIRE' be coded?
- Stack the words vertically: W -> Y, A -> C, T -> V, E -> G, R -> T.
- Convert to numbers: W(23)->Y(25) is +2. A(1)->C(3) is +2. T(20)->V(22) is +2. E(5)->G(7) is +2. R(18)->T(20) is +2.
- Identify the pattern: The rule is simply +2 to every letter.
- Apply the rule to 'FIRE': F(6) + 2 = H(8). I(9) + 2 = K(11). R(18) + 2 = T(20). E(5) + 2 = G(7).
- Combine the resulting letters: H, K, T, G.
Answer: HKTG
Common mistakes
- Ignoring wrap-around: Forgetting that adding to Z wraps around to A (e.g., Z + 2 = B) leads to calculation errors.
- Stopping after the first letter: Assuming the shift rule is constant (e.g., +1 everywhere) just because the first letter is +1. The pattern might be +1, -1, +1, -1.
Glossary
- mathematical
- Related to numbers and operations like addition or subtraction.
- positional
- Relating to the exact place or order of a letter in the alphabet.
- alignment
- Placing things in a straight line, like matching original letters directly over coded letters.
Recall questions
- What is the first physical step you should take when solving a coding problem?
- If vertical letter shifts don't reveal a pattern, what is the next structural pattern to check?
- How do you handle a shift operation that goes past 'Z'?
Questions & answers
If 'BEAT' is coded as 'CDBS', how is 'JUMP' coded?
KTNO
Approach: Stack BEAT and CDBS. Pattern: B(+1)=C, E(-1)=D, A(+1)=B, T(-1)=S. The rule is alternate +1, -1. Apply to JUMP: J(+1)=K, U(-1)=T, M(+1)=N, P(-1)=O.
If 'CAT' is coded as '24', what is 'DOG' coded as?
26
Approach: Substitute letters with their alphabetical positions: C(3) + A(1) + T(20) = 24. For DOG: D(4) + O(15) + G(7) = 26.