> LATTICE CIPHER
The idea in plain English: Imagine a piece of graph paper with letters placed at specific (x, y) coordinates. A is at (0,0), B is at (1,0), C at (2,0)... like a spreadsheet where row 0 is A-Z, row 1 is another set of symbols, etc. To encode a message, look up each letter's coordinate. To decode, do the reverse — given coordinates, find the letter at that position. Like reading a map with a grid reference.
Why this really exists: Coordinate-based encoding is everywhere. QR codes use a grid of black and white squares — your phone reads the grid to decode the URL. Barcodes are one-dimensional coordinates (width of stripes). GPS coordinates work the same way: latitude and longitude tell you your position on Earth. The lattice cipher is the simplest version of a spatial encoding — representing information by position.
▸ Concrete Example
A 3×3 grid with letters arranged in rows:
(0,1)=D (1,1)=E (2,1)=F
(0,2)=G (1,2)=H (2,2)=I
Ciphertext: [(2,0), (1,1), (0,2), (2,1), (2,2)]
Decode: (2,0)=C, (1,1)=E, (0,2)=G, (2,1)=F, (2,2)=I
→ "CEGFI"
The grid can be any size, and letters can be in any order (not necessarily A-Z). The puzzle data tells you the coordinate mapping.
▸ How to Decode (Step by Step)
1. Get the coordinate grid (a map of (x,y) → character)
2. Get the ciphertext coordinates (list of x,y pairs)
3. For each (x,y), look up the character at that position
4. Join the characters in order → the decoded message!
coords = [(2,0), (1,1), (0,2), (2,1), (2,2)]
plain = ''.join(grid[xy] for xy in coords)
💡 Higher difficulty levels use larger grids with non-sequential letter arrangements, making it harder to guess missing positions. But the decoding algorithm is always the same — look up coordinates in the grid.
▸ Real-World Applications
- QR codes: A grid of modules (black/white squares) encoding URLs, contact info, etc.
- GPS coordinates: Latitude/longitude pairs specify any position on Earth
- Spreadsheet cells: "B3" means column B, row 3 — the same (col, row) coordinate system
- Bitmap images: Each pixel is addressed by its (x, y) position on screen
- Battleship game: "A4" means column A, row 4 — classic coordinate guessing