Seating Chart Generator

The random part of a seating chart is trivial. The constraints are the whole problem, and a tool that silently drops one you asked for is worse than a tool with no constraints at all.

Row 1 is the front
Leave empty to place everyone at random
Blocks side-by-side and front-to-back adjacency. Diagonals are allowed.
Random Seating Chart Generator — Fixed Seats and Keep-Apart PairsBuildFigure

How a chart gets built

Pinned people are placed first. Everyone else and every remaining seat are shuffled independently with Fisher-Yates and paired off, which gives a uniformly random assignment over the free seats. That arrangement is then checked against the keep-apart list. If any listed pair ended up orthogonally adjacent the whole arrangement is discarded and the process starts again, up to four hundred times.

This is rejection sampling, and it has a property worth knowing: the chart you get is drawn uniformly from the arrangements that satisfy every constraint, not nudged towards one by a repair step. A tool that fixes a violation by swapping two people would produce charts that are legal but not evenly distributed, and over a term of weekly reshuffles the bias would show. The cost is that very tight constraint sets take many attempts or never succeed, which is what the failure message is for.

When it cannot be done

If four hundred attempts all fail, the page shows the closest arrangement it found and names every pair that is still adjacent in it. It does not quietly drop a constraint and present the result as if everything was satisfied. Three situations account for almost all failures:

CauseSymptomFix
Pinned pair is itself a keep-apart pairFails every time, instantlyMove one pin, or drop the pair
No spare seats and many constraintsFails after all four hundred triesAdd a column so there are empty seats to absorb the constraints
One person kept apart from several othersFails intermittentlyPin that person to a corner instead

The corner trick is worth remembering generally. A seat in the corner of the grid has two orthogonal neighbours instead of four, so pinning a person there halves the number of ways a keep-apart constraint involving them can be violated. Pinning the two ends of a difficult pair to opposite corners turns a probabilistic problem into a certainty.

What adjacency means here

Keep-apart blocks side-by-side and directly-in-front-or-behind. Diagonals are allowed. That choice is deliberate: extending the rule to diagonals raises the blocked-neighbour count from four to eight and makes most realistic constraint sets unsatisfiable in a full room. If two people genuinely must not be within talking distance, adjacency is the wrong tool and pinning is the right one.

Empty seats scatter at random through the grid rather than collecting at the back, because they are treated as ordinary seats that nobody drew. If you want the gaps at the back, reduce the row count until the seat total is close to the head count and the remaining gaps will be few enough not to matter.

Pinning syntax

One person a line, written as the name, an equals sign, the row and the column: Avery = 1, 3. Row 1 is the front of the room and column 1 is the leftmost seat as you look at the class from the front. Names must match the name list exactly, including capitalisation, and anything that does not parse is reported as an error rather than skipped — the chart is not generated at all until every line reads cleanly, so a typo can never cost someone their pinned seat without you noticing.

Questions people ask

What happens if my keep-apart pairs conflict?

The page tells you. It shows the best arrangement it found, marks every pair that is still adjacent in red in the constraints list, and states how many of your pairs it met. It never presents a partial result as a complete one. The most common cause is a pair that was also pinned into adjacent seats, which no amount of reshuffling can fix.

Does everyone have an equal chance of every seat?

Everyone not pinned has an equal chance of every free seat, yes, in the unconstrained case. Once keep-apart pairs are involved, the distribution is uniform over the arrangements that satisfy them, which is the fairest thing available — some seats become less likely for the constrained people because some arrangements are excluded, and that is unavoidable given what you asked for.

Can I keep certain people together instead of apart?

Not directly. The workaround is pinning: put both people in the specific adjacent seats you want them in, and the rest of the class shuffles around them. That is more reliable than a keep-together constraint would be, because it says exactly where rather than merely near.

Are the names stored?

No. The list is read from the textarea, shuffled in your browser and rendered on the page. Nothing is transmitted and nothing persists after the tab closes. Copy the text output if you want to keep the chart.

Related