Coding–Decoding – Reasoning Ability
Topic – Puducherry PSC / IIT‑JEE style
Goal – Equip you with a systematic, exam‑oriented approach to solve coding‑decoding problems efficiently.
1. What is Coding‑Decoding?
| Term | Description |
|---|---|
| Coding | Assigning a code (number, letter, symbol, etc.) to a given item. |
| Decoding | Determining the original item from its code. |
Typical problems give you a sequence (letters, numbers, words, or mixed) and ask you to find the next element, map an item to its code, or decode a given symbol.
2. Classification of Problems
| Category | Typical Input | Typical Output | Common Patterns |
|---|---|---|---|
| Alphabetic | A, B, C, … | X, Y, Z, … | Linear shift, reverse, skip, alternating |
| Numeric | 1, 2, 3, … | 5, 9, 13, … | Arithmetic/Geometric, Fibonacci, prime, square |
| Mixed | A1, B2, … | 1A, 2B, … | Interleaving, position‑based mapping |
| Word/Letter‑group | “CAT”, “DOG” | “CQT”, “DGF” | Letter‑by‑letter mapping, word‑length based |
| Pattern‑based | 1A, 2C, 3E, … | 4G | Combination of two independent patterns |
| Symbolic | ♠, ♥, ♦ | 5, 6, 7 | Base‑conversion, positional value |
Tip – Start by identifying what is changing: letter, number, both, or a property (odd/even, prime, etc.).
3. General Strategies
| Step | What to Do | Why |
|---|---|---|
| 1. List the given terms | Write them in a table. | Visual clarity, easier detection of gaps. |
| 2. Check for linearity | Find differences (Δ), ratios (Δ/prev). | Many coding problems use arithmetic/geometric sequences. |
| 3. Check for letter‑by‑letter mapping | Compare each character in successive terms. | Works for word‑based coding. |
| 4. Look for positional rules | Use positions (1,2,3,…) to decide mapping. | Alternating or “skip‑k” rules. |
| 5. Check for base/positional value | Convert to/from base‑2, base‑3, etc. | Symbolic coding often uses binary/ternary. |
| 6. Verify with constraints | Ensure uniqueness, avoid contradictions. | Many exam questions allow only one valid answer. |
| 7. Back‑track if needed | If multiple possibilities, test each against all given terms. | Confirm the correct rule. |
4. Common Patterns & Formulae
| Pattern | Example | How to Derive |
|---|---|---|
| Linear shift (ROT‑n) | A → D, B → E, … | code = (plain + n) mod 26 |
| Reverse | A → Z, B → Y | code = (25 - index) |
| Skip | A → C, B → D | code = (plain + 2) |
| Alternating | A → C, B → D, C → E, D → F | code = (plain + 2) for odd positions, +1 for even |
| Position‑dependent | 1A, 2C, 3E … | letter = (index + 1); number = index |
| Arithmetic on numbers | 2, 5, 10, 17 | Δ = 3, 5, 7 … ⇒ Δ_n = 2n+1 |
| Geometric on numbers | 3, 9, 27 … | ratio = 3 |
| Fibonacci | 1, 1, 2, 3, 5 … | a_n = a_{n-1} + a_{n-2} |
| Prime | 2, 3, 5, 7, 11 … | next prime |
| Square | 1, 4, 9, 16 … | n^2 |
| Base‑conversion | 1, 10, 11, 100 (binary) | Convert decimal → binary, or vice versa. |
| Mixed letter‑number | 1A, 2B, 3C | Pairing index and letter. |
Important Formulae
| Formula | Usage |
|---|---|
code = (plain + k) mod 26 |
Rotating alphabets. |
code = (25 - plain) |
Mirror mapping (A↔Z). |
Δ_n = Δ_{n-1} + d |
For arithmetic progression with varying difference. |
a_n = a_{n-1} * r |
Geometric progression. |
prime(n) |
Next prime after n. |
n^2 |
Square numbers. |
C(n, k) |
Combinatorial patterns (rare). |
5. Tricky Points & Pitfalls
| Pitfall | What to