Transposition cipher

Rail Fence Cipher Practice: Solve the Zigzag

The letters never change, they just get shuffled onto a zigzag. Learn to put them back in order, with a worked example and free puzzles.

A rail fence cipher is the simplest kind of transposition. Most ciphers swap one letter for another. This one keeps every letter exactly as it is and only changes the order. You write the message diagonally down and up across a few rows (the rails), bouncing off the top and bottom like a zigzag fence, then read the rails one after another. It is also called the zigzag cipher.

Cipher Munch Rail Fence puzzle: a card reading Rails: 2, the cipher letters in blocks with answer boxes beneath, and a small zigzag helper above the keyboard
A Rail Fence puzzleThe rail count is on the card
The Rail Fence Options sheet in Cipher Munch with a Reveal a letter card, switches for Show rail fence and Highlight errors when complete, the on-screen keyboard, Text size and Print / share
Rail Fence OptionsShow rail fence, errors, print

How it works

Take HELP IS ON THE WAY on 3 rails (spaces are dropped). The letters land like this, one column per letter:

Read each rail left to right and join them: HITA + EPSNHWY + LOE gives the cipher HITAEPSNHWYLOE.

Decoding it

Decoding is the same drawing run backwards, and you are told the number of rails.

  1. Count the cipher letters (14 here).
  2. Sketch the zigzag with 14 empty spots and count how many fall on each rail: 4, 7 and 3.
  3. Fill the rails in order: the first 4 letters go on rail 1, the next 7 on rail 2, the last 3 on rail 3.
  4. Read along the zigzag, down and up, and the message appears.

Two shortcuts: the first cipher letter is always the first letter of the message, and the first letter of rail 2 is always the second. One full V (down and back up) uses 2 × (rails − 1) letters, so 4 on 3 rails and 6 on 4 rails. Because nothing was swapped, counting letters tells you nothing here. It is all about where each letter belongs. And since there is no punctuation or spacing, look for short words like THE, AND and OF to find where words start and stop.

In the app

The card at the top shows Rails: N, from 2 to 6, and the board shows the cipher with a gap after each rail so you can see how many letters each one holds. You type the message in reading order. Under the board, a zigzag helper has already placed each rail's letters for you, and the box you pick gets outlined in the fence. In Options, under Display, Show rail fence is that helper (turn it off to draw the zigzag yourself) and Highlight errors when complete marks wrong letters once every box is filled. There is no frequency table for Rail Fence, because none of the letters change. Print / share makes a worksheet with each rail in its own block and room to write the message underneath, so you can practice on paper.

Codebusters

Rail Fence is not on the 2027 Science Olympiad Division C Codebusters list. It has appeared in earlier seasons, usually with the number of rails given, and it is still great training for the transposition thinking you need for Complete Columnar, which is on the 2027 list.

Practice it

In the app's Reference & Flashcards screen, the English Patterns by Frequency deck drills the most common English words, which helps you spot them in a long run of letters with no spaces. Flip the cards, swipe them into Know or Still learning, then try the multiple-choice Test. Not sure how many rails a message uses? Try each count in turn. The wrong ones read as nonsense from the start, and the right one gives words.

Put the zigzag back together

Rail Fence has a free Starter pack in Cipher Munch, with a helper fence that does the drawing for you. No ads, no account, works offline.