Traffic Jam

The red car is boxed in by others in a crowded car park, and every car can only roll forwards or backwards along the lane it already sits in. Shuffle the rest out of the way until there is a clear run to the exit.

How to play

The gap the red car is heading for is on the right-hand side, and since it only travels along its own line, that is the only way out it will ever have.

  1. Drag a car along its own axis Or just tap it to nudge it forward one square.
  2. Work out what blocks the red car Then what blocks that, and so on.
  3. Free the exit row The red car can only leave through the gap on the right.
Full instructions
In depth

Solving Sliding Block Puzzles in Fewer Moves

This guide walks through the rules of the sliding car puzzle, explains how the move limit is set, and shares the backward-reasoning method that turns trial and error into a plan.

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

Where each level's move budget comes from

The two numbers on the panel, Fewest possible and Moves left, both come out of one search that runs when a level loads. The game copies the car list and puts that starting board in a queue. It takes the front board off the queue, asks whether the red car has reached the exit, and if not it adds every board that is one legal slide away. Boards are handled in the order they were added, so the first winning board it meets was reached by the shortest run of slides. That count is Fewest possible.

The move budget is then one line of arithmetic on that count. The limit is the fewest possible plus the larger of two things: a flat 6, or 60% of the fewest possible, rounded to a whole number. The smallest cushion you can ever be given is therefore six spare moves. The 60% share only wins that comparison once the shortest answer reaches 11 moves. At 10 the two are equal, and below 10 the flat 6 is always the bigger of the pair.

Level one shows the whole sum. Four cars sit on the grid: the red car on row 3 at the far left, a flat car on the top row, an upright car three squares long in column 4, and a flat car on the bottom row. The upright car fills the top three squares of its column, which puts it straight across the red car's row. It cannot back up, because it is already touching the top edge. So it has to drop three squares before its top clears row 3. The red car then needs four slides to the right, from column 1 to column 5. Three plus four is seven, and the search returns 7. The budget works out as 7 + the larger of 6 and 4, which is 7 + 6, so Moves left starts at 13 and you have six moves of slack.

Level two is where the percentage takes over. Its shortest answer is 13 moves. Sixty percent of 13 is 7.8, which rounds to 8, and 8 beats the flat 6, so the budget is 13 + 8 = 21. Level four works the same way: 11 moves shortest, 60% of 11 is 6.6, that rounds to 7, and the budget is 18.

One square of travel by one car is one move. Pushing a car that has no room costs nothing at all. The legality test runs first, and a blocked push just plays a short low tone and leaves the counter alone. The win check also runs before the budget check, so a winning slide made with your very last allowed move still counts as a win rather than a loss.

  • Level 1, four cars: fewest possible 7, budget 13.
  • Level 2, eight cars: fewest possible 13, budget 21.
  • Level 3, seven cars: fewest possible 6, budget 12.
  • Level 4, eight cars: fewest possible 11, budget 18.

What the search skips, and what your best score really records

The boards are not generated. There are four of them, typed out by hand as lists of four values per car: row, column, length, and whether the car lies flat. You get the same four boards in the same order on every visit. There is no seed, no size option and no random mode.

The shortest answer does not climb steadily either. Level two needs 13 moves, but level three needs only 6. On level three a single upright car fills the top three squares of column 5, and that is the only thing standing in the red car's row. Drop it three squares and the red car has three clear slides to the finish. Three plus three is six. So the third board is roomier than the second, even though it comes later. The level number is the order the boards were written down, not a ranking of how hard they are.

Your move count is set back to zero every time a level loads. That matters for the best score. When you clear the fourth board, the number handed to the scoreboard is the count for that fourth board on its own, not the four levels added together. The lowest figure you could ever save is 11. Running out of moves saves nothing, because the game hands over an empty score in that case, and an empty score is never written to the record.

The search takes two shortcuts that are safe but worth knowing about. A board is remembered as each car's row and column, joined into one string in list order. Length and direction are left out, since neither ever changes. That means two cars of the same shape which have swapped places count as two different boards, so the search can look at more boards than it strictly needs to. That only makes it slower, never wrong. There is also a hard stop after 200,000 boards have left the queue. If it ever tripped, Fewest possible would show a dash and the budget would fall back to 32. The four boards here are nowhere near it. The longest of the four takes 1,102 boards off the queue, and level one settles after 111.

The finish test looks only at the red car's column: its left square plus its length has to reach 6. It never checks the row. That is safe because a flat car can never change rows, so the red car stays on row 3 all game. It also means the red car does not drive off the board on screen. It wins the instant it fills the last two squares of its row.

There is no clock, no undo and no part marks for getting close. Restart level puts the same board back and sets your count to zero, so a restart is free, but it also throws away whatever you had already spent on that board. A tap always pushes a car forward, which means right for a flat car and down for an upright one. Going left or up needs a drag, and a drag only registers after the pointer has travelled 60% of one cell. A cell is the board's width divided by six, so on a board 360 pixels wide that is a pull of about 36 pixels. After a win the next board arrives 700 milliseconds later, and the old board is still live during that short pause.

How the puzzle works

A six-by-six grid holds several cars of different colours. One car is red. The red car sits on the third row and must reach the gap on the right-hand edge. Every other car is in the way, and your job is to slide them aside until the path is clear.

Each car can only slide along the direction it faces. A horizontal car moves left and right but never up or down. A vertical car moves up and down but never sideways. No car can pass through another, and no car can leave the grid. These two constraints are what turn a simple grid into a real puzzle.

Controls on desktop and phone

On a desktop, click a car and drag it along its own axis. On a phone, the same drag gesture works with touch. If you prefer, you can tap any car once to nudge it forward one square in its natural direction. A nudge is quicker for small adjustments and avoids the wobble that sometimes happens with a short drag.

Two buttons sit below the board. Restart level puts all the cars back where they started on the current puzzle. New game resets to the first level. Each move is one square of travel for one car, regardless of whether you dragged it or tapped it.

Levels and move limits

There are four levels, each harder than the last. The game starts at level one and moves to the next automatically when you drive the red car out. Clear all four and the game ends with a win.

Every level shows a figure called Fewest possible. That number is exact. Before a level is offered, every reachable arrangement of cars on the grid is explored shortest-first by a breadth-first search. The first arrangement in which the red car reaches the exit is provably the shortest solution. Nothing can do it in fewer moves. The move limit you are given is that shortest solution plus a comfortable margin, so you have room for wrong turns without being forced to play perfectly.

Scoring

The stats panel shows three things: the current level out of four, the fewest possible moves for that level, and how many moves you have left before the limit. Your total across all four levels is saved as your best if you clear them all. Lower totals are better.

Running out of moves on any level ends the game. The message tells you the shortest solution for that level and suggests the backward-reasoning approach described below.

Walking through a simple level

On the first level you will see the red car on the third row near the left edge, a horizontal car across the top row, a vertical car standing in a column near the middle, and another horizontal car along the bottom. The red car needs to slide right until it reaches the gap. The vertical car in the middle blocks the third row, so the red car cannot pass.

The question is: what blocks the vertical car? Check whether it can slide up or down. If a car sits above it, that car must move first. Trace the chain one step at a time. On this first level the chain is usually short, perhaps two or three moves to clear the blocker and then one or two more to drive the red car out. The fewest-possible figure for level one is low, so the margin is generous and you have several spare moves to experiment.

How the levels get harder

Each level adds more cars to the grid. More cars means longer chains of dependencies. On level one, one or two cars block the exit row. By level four, the blocking chain can reach five or six cars deep, and moving one car often blocks a different path that you will need later.

The grid size stays the same at six by six. What changes is the density. With more cars packed into the same space, the number of possible arrangements grows fast, and the shortest solution requires more moves. The margin above the minimum stays fair, but you have to plan further ahead because wrong turns cost more when the chain is longer.

Strategy: reason backwards from the exit

The most useful habit is to start from the end and work backward. Look at the exit gap on the right side of the third row. What is sitting between the red car and that gap? Usually one or two vertical cars. Ask what would have to move for each of those cars to get out of the way. Then ask what blocks those cars.

This chain of questions builds a short plan. The first car you need to move is usually the last one in the chain, not the one touching the red car. Beginners often push the nearest obstacle first, only to find that the car they moved has nowhere useful to go because something else is still in the way.

Strategy: watch for dead zones

Some areas of the grid have no cars that need to move. Pushing a car into one of those areas early gives it a safe parking spot that will not interfere with later moves. Corners are often good for this. A vertical car tucked against the top edge in the far left column is out of the way for the rest of the puzzle.

The opposite is also true. The centre of the grid is crowded and every square there is contested. Moving a car into the middle of the board without a clear reason usually makes things worse, because that car will need to move again when something else needs to pass through.

Strategy: count the minimum chain

Once you have traced the chain from the exit back to the first blocker, count the moves. If the chain needs four moves and the shortest possible is five, you know there is at most one extra step you have not found. That narrows the search enormously.

If your chain needs twelve moves and the minimum is six, your plan has a shortcut hiding somewhere. Look for a single slide that clears two blockers at once. A long car moved one square can open a path for the car behind it and close nothing important. These double-duty moves are where the biggest savings come from.

Why some cars are longer than others

Most cars occupy two squares, but some occupy three. A three-square car takes up more room and is harder to park out of the way. It also has less freedom to slide, because even one square of movement requires an empty square at the far end, and three-square cars bump into the edge of the grid sooner.

On the other hand, a long car sitting across multiple rows or columns can block more paths at once. Moving one long car out of the way sometimes clears two separate routes in a single slide, which is why the minimum move count on some levels is lower than you might expect. The solver finds these double-clearance moves automatically. Learning to spot them yourself is how you start matching the fewest-possible figure.

Common beginner mistakes

The most common mistake is pushing cars at random until something opens up. On the first level this can work because the grid is simple. By level three the number of possible arrangements is large enough that random moves almost never converge.

The second mistake is forgetting that cars only move one way. A horizontal car that looks like it is blocking the red car cannot be moved up or down to get out of the way. It must be pushed left or right, and whatever is at the end of that slide matters. Check both directions before you commit.

The third is not using the restart button. If you have shuffled things into a worse state than the starting position, restarting the level costs nothing and is usually faster than untangling the mess. There is no penalty for restarting.

A fourth error is tunnel vision on the exit row. The exit is on the third row, but the solution often starts with moves on the first, fifth, or sixth row. Cars far from the red one still matter if they block something that blocks something that blocks the exit. Scan the whole grid before you start sliding.

Privacy and saved data

The entire puzzle runs inside your browser. No data is uploaded, no account is needed, and your best move count is saved in local storage on this device only. The page works offline once it has finished loading.

Help

How to play Traffic Jam

The gap the red car is heading for is on the right-hand side, and since it only travels along its own line, that is the only way out it will ever have. The cars pointing across the board are the ones to plan around: they slide up and down and can be moved clear of the lane, while the ones lying alongside cannot.

Drag a car along its own axis

Or just tap it to nudge it forward one square.

Work out what blocks the red car

Then what blocks that, and so on.

Free the exit row

The red car can only leave through the gap on the right.

Watch the move count

Fewest possible is the true minimum, worked out for each level.

Finish all four levels

Each is harder than the last.

Runs on your device

The whole game is played inside this page. Nothing is uploaded, there is no account, and your best score is stored in this browser only. Once the page has loaded it works offline.

Good to know

Work backwards from the exit

Ask what has to move for the red car to reach the gap, then what has to move for that. Pushing cars around at random rarely converges.

Cars only move one way

A car lying across the board can never move up or down. That constraint is what makes the puzzle hard and also what makes it solvable by reasoning.

The minimum is exact

It is found by exploring every reachable arrangement shortest-first, so "fewest possible" is a fact rather than a guess.

Restart is not failure

If you have shuffled things into a mess, restarting the level is usually faster than untangling it.

Common questions

Why can I not move that car sideways?
Cars only slide along the direction they are pointing. A horizontal car moves left and right, a vertical one up and down.
Is the fewest possible figure real?
Yes. It comes from a full breadth-first search of every reachable board position, so nothing can do it in fewer moves.
How do I move a car on a phone?
Drag it along its own axis, or tap it to nudge it one square forward.
Is it free?
Yes — no account, no limit on how many games you play, and no ads inside the game area itself. Ads on the page around it pay for the site.
Does it work on a phone?
Yes. The board scales to your screen and the controls are made big enough to use with a thumb.
Where is my best score kept?
In your browser on this device. It is never sent anywhere and will not follow you to another computer.