Skip to content
100% local

Derangements

List and count derangements — permutations where no item stays in its original position.

Input
Output

Derangements

Paste a list, one item per line, and get every permutation in which no item ends up back where it started — the classic "derangement" of combinatorics, also called a permutation with no fixed points. Three items give 2 derangements, four give 9, five give 44 — the tool computes the exact count (the subfactorial, written !n) before it lists anything, so the live tally always shows what you are about to generate.

The letters mode deranges the characters of a single word instead of list lines, which is a quick way to check whether an anagram exists where every letter moves. With repetition switches from a strict one-to-one reassignment to positional sequences, where a position may reuse any item except the one that started there — useful for exploring looser "nobody keeps their own seat" arrangements rather than a true bijection. Duplicate items are removed by default so a repeated line does not multiply the output; separators are configurable — comma, space, tab, nothing, or a custom string with \t escapes.

Subfactorials grow almost as fast as factorials, so the limit option caps how many rows print without touching the reported count — set it to a handful of examples for a 20-item list whose full count would otherwise be unprintable, or to 0 to list everything the output size allows. Past the 10 MB output limit even a capped request is refused, with the count in the message, instead of freezing the tab.

Typical uses: Secret Santa assignments where nobody draws their own name, seating or task rotations that must avoid a self-match, and combinatorics teaching examples. Everything runs locally — your list is never uploaded; copy the result, download it as .txt, or send it back to the input to chain another step.

FAQ

What is a derangement?
A derangement is a permutation of a set where no element ends up in its original position — item 1 never lands back in slot 1, item 2 never lands back in slot 2, and so on. The classic example is a gift exchange where nobody should draw their own name.
How is this different from the permutation generator?
The permutation generator lists every possible ordering, including ones where some items stay put. This tool only lists the subset where every single item moves — a stricter, smaller count called the subfactorial (!n) instead of the full factorial (n!).
What does "with repetition" change?
Off, each derangement is a strict one-to-one reassignment (a true bijection). On, a position may reuse any item other than the one that started there, so the same item can appear more than once across a row — (n−1)^n sequences instead of !n.
Why would I set a limit below the full count?
Derangement counts explode quickly — a 20-item list already has over 895 quadrillion of them. The limit option lets you see a handful of valid examples without asking the browser to print an impossible number of rows; the exact total still shows in the tally either way.
Is my list uploaded anywhere?
No. Every derangement is computed entirely in your browser, and your list never leaves your device.