Description
Construct a no-fixed-point assignment by exact completion-count unranking, uniformly over all derangements under independent uniform random words.
Sampling selects from a supplied population under rules for replacement, grouping, or eligibility. Draw probabilities, inclusion probabilities, and repeat counts describe different aspects of selection; a reproducible sample is not automatically representative of a real population.
Construct a no-fixed-point assignment by exact completion-count unranking, uniformly over all derangements under independent uniform random words.
When to use this tool
Use this generator to create reproducible derangement assignment cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.
How to use the tool and how it works
- Supply ids in the field shapes below. Set seed when you need an explicit replay.
- Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
- Read assignments, cycles, exactCount, sampledRank. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.
Count fixed-point-free permutations using subset dynamic programming and cross-check the independent derangement recurrence. Draw a bounded unbiased integer rank and unrank it through completion counts; return assignments, permutation cycles, exact count, and sampled rank as decimal strings.1
Delegated operations used for this result: derangement number. Their calculation or parsing conventions apply to the corresponding result fields.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| ids | Ids | Required. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 2; maximum items 16. |
| seed | Optional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed. | Optional. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| assignments | Assignments | Required. Array of Object; no unknown keys.; minimum items 2; maximum items 16. |
| assignments[].from | From | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| assignments[].to | To | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| cycles | Cycles | Required. Array of Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 2; maximum items 16.; minimum items 1; maximum items 8. |
| exactCount | Exact Count | Required. Text. |
| sampledRank | Sampled Rank | Required. Text. |
| randomness | Replay source and normalized 32-bit seed, or null seed for an advancing context source. | Required. Object; no unknown keys. |
| randomness.seed | Optional safe-integer replay seed; normalization and precedence are explained below. | Required. Safe integer. or Null. |
| randomness.source | Source | Required. Text; one of "context", "seed". |
An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.
{
"input": {
"ids": [
"A",
"B",
"C",
"D"
],
"seed": 42
},
"output": {
"assignments": [
{
"from": "A",
"to": "B"
},
{
"from": "B",
"to": "A"
},
{
"from": "C",
"to": "D"
},
{
"from": "D",
"to": "C"
}
],
"cycles": [
[
"A",
"B"
],
[
"C",
"D"
]
],
"exactCount": "9",
"sampledRank": "0",
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- IDs must be distinct and the small bank limit bounds exponential work. Uniformity refers to complete derangements under the random-source convention, not independent destination choices or fairness across repeated calls. A derangement can contain several cycles.
- A replay requires the same complete input and implementation. The stated sampling convention applies within its eligible space. A finite draw does not exhaust all possible outputs; repeats remain possible unless a distinct-selection rule is explicit.
- The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.
Alternative or Complementary methods
For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.
References
Similar or alternative tools
- Random Balanced Factorial Assignment Generator
Construct every supplied factor combination and randomly assign distinct units under exact equal replication quotas for caller-reviewed experiments.
- Random Cluster-Based Row Sample Generator
Draw supplied cluster IDs under explicit cluster weights and return every original row per selected cluster occurrence with conditional draw probabilities.