Siding

Shunt railway wagons into a siding, a short dead-end stretch of track where the only way out is back the way they went in: last in, first out. Getting them into the order you need is the puzzle.

How to play

Three moves are all you get: push the next arriving wagon into the siding, send it straight past to the departure road, or pull the wagon nearest the buffer back out and away.

  1. Read the wanted order The top row is the order the train must leave in. Ghosted wagons are ones you have not made up yet.
  2. Decide before you push A wagon sent straight through can never be moved again, and a wagon pushed in can only come out on top.
  3. Watch the siding fill It has a limit. Filling it with wagons you cannot yet release is the usual way to get stuck.
Full instructions

In depth

One dead end, one stack, and the orders that cannot be shunted

Siding is a railway shunting puzzle that teaches a deep piece of computer science while pretending to be about trains. Wagons arrive in one order and must leave in another, and all you have is a single dead-end siding. Because the siding is a dead end, the last wagon you push in is the first that can come out. That constraint is exactly what makes some orders possible and others genuinely impossible, and understanding why is the real lesson hiding inside the game.

Screenshot: How to play Siding
How to play Siding as it appears when the page opens.

How the puzzle works

A line of wagons arrives at one end of the yard, each marked with a letter. A second line at the top of the screen shows the order they must leave in. Between the two sits a single siding, a dead-end track that can hold a limited number of wagons. Your job is to shunt every wagon from the arriving road to the departure road in the order asked for, using the siding as a buffer when the next wagon you need has not arrived yet.

Each turn you make exactly one of three moves. You can push the next arriving wagon into the siding. You can send the next arriving wagon straight through to the departure road. Or you can pull the top wagon out of the siding onto the departure road. There is no fourth option and no way to rearrange wagons once they are on the departure road or deep inside the siding stack. The constraint is total: wagons travel from the arriving road to the siding, from the arriving road to the departure road, or from the top of the siding to the departure road. No other direction is ever allowed.

Controls and interface

Three buttons drive the puzzle. Push into siding takes the front wagon from the arriving road and places it on top of the siding stack. Straight through sends the front arriving wagon directly to the end of the departure road. Pull from siding takes the top wagon off the siding and adds it to the departure road. Each button greys out when its action is not available, so you always know what you can do.

The top row shows ghosted wagons in the wanted order. As each wagon reaches the departure road in the correct position, its ghost fills in. A wagon landing in the wrong position ends the round immediately, because the departure road cannot be reshuffled. The siding row shows its current fill and its maximum capacity.

Scoring and the par system

Your score is the number of moves it takes to assemble the correct departure order. The game searches every legal sequence of pushes, pulls and straight-throughs to find the true minimum, which it displays as the par. Every wagon costs at least one move, and any wagon that visits the siding costs two, so the par is always at least as large as the number of wagons. Matching the par means you found the absolute shortest solution, because the search is exhaustive.

You are given a budget of moves equal to the par plus a small cushion. Run out of moves before the train is assembled and the round ends. A wrong wagon on the departure road also ends the round instantly, since the departure road cannot be reshuffled. Your best score is tracked across sessions, stored in your browser on this device and never sent anywhere. Lower scores are better, and the game tells you how your finish compared with the minimum.

Difficulty levels

The Train selector offers three sizes. Small gives you four wagons and a siding that holds three. Medium raises the count to five wagons with the same siding capacity. Large uses six wagons and increases the siding to four slots. The larger trains are harder not because the siding fills faster, but because there are more wagons competing for limited buffer space and the look-ahead becomes longer.

At every level the game guarantees that the order it asks for can actually be shunted. It does this by running a random shunt on a real train and writing down whatever comes out. That output is always reachable by definition, which avoids handing you an impossible task.

Strategy: reading the wanted order before you move

The most important habit is to scan the entire wanted order before touching anything. Look for wagons that are already in the right position in the arriving line. A wagon that needs to leave in the same position it arrives in should go straight through, because routing it through the siding wastes two moves instead of one.

Next, look for runs of wagons that need to leave in reverse order. The siding reverses whatever you push into it, so three consecutive wagons that must depart in backward order can be pushed in together and pulled out in the correct sequence. Spotting those runs is the key to matching or beating the par.

Strategy: managing siding capacity

The siding has a hard limit, and filling it with wagons you cannot yet release is the most common way to lose. Before pushing a wagon in, ask yourself whether you will be able to pull it out before the siding overflows. If the wagon on top of the siding is not needed until much later, every wagon pushed on top of it must also not be needed until after that one leaves.

A useful rule of thumb is to avoid pushing a wagon into the siding unless the wagon currently on top will be needed before or at the same time. Stacking two wagons that are both needed late creates a bottleneck that only gets worse as arrivals continue.

Common mistakes and how to avoid them

The fastest way to fail is sending a wagon straight through when it is not the next one wanted. Once a wagon is on the departure road it cannot be moved, so a single misplaced wagon ends the round. Always check the wanted row before pressing straight through.

Another frequent error is pushing too eagerly. Every push uses a move and commits you to pulling that wagon out later, which is a second move. If the wagon you need next is arriving, there is no reason to route it through the siding at all. Sending it straight through saves a move every time.

Forgetting that the siding reverses order is a subtler trap. Two wagons pushed in as A then B come out as B then A. If you need them in the original order, pushing both into the siding actually makes the problem worse.

Why some orders are impossible with one siding

A dead-end siding is exactly what computer scientists call a stack: last in, first out. Not every order can be produced with a single stack, and the impossible ones all fail for the same structural reason. If three wagons arrive as A, B, C and you need C first, then A, then B, the siding cannot help. Getting C out first means A and B must both be in the siding with A underneath. They can only come out B then A, never A then B.

With four wagons, exactly fourteen of the twenty-four possible orders can be shunted. That count is the fourth Catalan number, and the sequence continues as the train grows. With five wagons the count rises to forty-two out of a hundred and twenty, and with six it is a hundred and thirty-two out of seven hundred and twenty. The game never offers an impossible order, but knowing why they exist turns each puzzle from guesswork into deduction. You start looking for the three-wagon pattern that would trap you, and that look-ahead is exactly what good play requires.

Privacy and how the game runs

The entire puzzle runs inside your browser tab. Nothing is uploaded, there is no account, and your best score stays on this device in local storage. Once the page has loaded it works offline, so you can solve shunting puzzles on a train or a plane without a connection.

The par is computed by a breadth-first search over every legal move sequence, so the answer is exact rather than estimated. The puzzle generator works the same way: it shunts a real train at random and records the output, then verifies the order by searching for the shortest solution. If the result would be trivial, such as the arriving order being the same as the wanted order, the generator tries again. The entire process takes a fraction of a second even on a phone.

Help

How to play Siding

Three moves are all you get: push the next arriving wagon into the siding, send it straight past to the departure road, or pull the wagon nearest the buffer back out and away. The order they must leave in is shown before you start, so the question is always whether the wagon in front of you is wanted now or wanted later.

Read the wanted order

The top row is the order the train must leave in. Ghosted wagons are ones you have not made up yet.

Decide before you push

A wagon sent straight through can never be moved again, and a wagon pushed in can only come out on top.

Watch the siding fill

It has a limit. Filling it with wagons you cannot yet release is the usual way to get stuck.

Make up the train

A wagon on the departure road in the wrong place ends the round at once — there is no shuffling it back.

What a single dead end can and cannot do

A dead-end siding is exactly what computer scientists call a stack, and only some orders can be made with one. The impossible ones all fail the same way: look for three wagons where a LATE arrival leaves first, and the two earlier ones leave after it still in their original order. Say wagons A, B and C arrive in that order and you want C, A, B. To get C out first, A and B must both be in the siding — A underneath, B on top — so they can only come back out B then A. C, A, B cannot be made, and no amount of shuffling changes it. With four wagons exactly fourteen of the twenty-four possible orders can be shunted, which is the fourth Catalan number, and the count keeps following that sequence as the train gets longer. Every order offered here is generated by shunting a real train at random and writing down what came out, so it is always one of the reachable ones. The par is found by searching every legal sequence of pushes and pulls, so it is the true minimum.

Good to know

Look for the next one wanted

If the wagon you need next is arriving, send it straight through. If it is on top of the siding, pull it. Otherwise you must push.

The siding reverses

Wagons pushed in come out backwards. Three wagons that need reversing go in together and come out in order.

Some orders are impossible

Not here — every order offered can be shunted — but in general one dead end cannot produce every order, and knowing why is the real lesson.

Count the moves

Every wagon costs at least one move and any that visits the siding costs two. The par is the fewest possible.

Common questions

Can I take a wagon off the departure road?
No. Once it has left it is made up, which is why a wrong wagon ends the round.
Can I push a wagon from the departure road into the siding?
No. Wagons only ever travel arriving to siding, arriving to departing, or siding to departing.
Why is the siding capacity limited?
To keep the puzzle honest. With unlimited room some orders become trivial.
Is every order possible?
No. With four wagons only fourteen of the twenty-four orders can be shunted with one dead end. Every order this game offers is one of the reachable ones.
Does the shortest solution use the siding?
Usually, but not always. A wagon that is already in the right place should go straight through.