Constrained Shuffle Generator
A shuffled quiz should not have two music rounds together, and a shuffled playlist should not have two songs by the same artist back to back. That constraint is achievable exactly when no category holds more than half the items, rounded up — and impossible otherwise, however long you shuffle. This arranges the list when it can, and tells you plainly when the arithmetic rules it out.
What this generator does
Checks first whether an arrangement can exist at all, then builds one by repeatedly taking an item from whichever eligible category has the most left — the rule that keeps a large category from being stranded at the end.
How to use this tool
- List your items, one per line, as a name and a category.
- Generate, and read the order.
- Check that no two neighbours share a category.
- Try making one category more than half and see the refusal.
Understanding the controls
- Items and categories
- One per line as a name and a category, separated by a comma. Categories are matched case-insensitively, so \u201cMusic\u201d and \u201cmusic\u201d are the same.
- Seed
- Reproduces the same order, which matters when a running order has been shared and then needs regenerating.
Common use cases
- Ordering quiz rounds so no two of a kind are adjacent
- Shuffling a playlist without two songs by the same artist together
- Arranging a running order so similar acts are spread out
- Spreading agenda items of the same type through a meeting
- Seeing when a no-adjacent arrangement is mathematically impossible
How this generator works
An arrangement with no two neighbours alike exists exactly when no category holds more than half the items, rounded up — so that is checked before any shuffling, and an impossible case is reported as impossible rather than as a search that failed. When it is possible, each position takes an item from whichever eligible category has the most remaining. Taking the scarcest instead is the intuitive choice and the wrong one: it strands the largest category at the end. Before display every neighbouring pair is checked and every item confirmed to appear exactly once.
Randomness and fairness
Uses your browser's cryptographic random source to choose between equally good options. A seed switches to a reproducible sequence, which is deterministic and not cryptographically secure.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Only adjacency is constrained: two items of a category can still be one apart, which is often fine and sometimes not.
- One category per item, so something belonging to two categories has to be assigned one.
- No other ordering preferences are supported — nothing can be pinned first or last.
- An impossible request is refused rather than approximated, which is the honest answer but not always the useful one.
Privacy and your data
Your list stays in your browser. Nothing is uploaded, and no item name is ever included in analytics — only the number of items.
Related generators
- Random Task Order GeneratorShuffle your to-do list into a random order to tackle top to bottom.
- Random Name PickerPaste a list of names and instantly pick one at random, fairly and without repeats if you choose.
- Quota Sampling GeneratorSplits a sample across groups in proportion to their size, with the quotas adding up to exactly the sample size and nobody picked twice.
- Riffle Shuffle CalculatorWorks out how far a deck still is from properly mixed after each riffle, and where the famous seven-shuffle answer comes from.
- Random Team GeneratorSplit a list of names into a chosen number of random, evenly sized teams.