Skip to content

Clarify how derangements treats duplicate inputs#1069

Merged
bbayles merged 1 commit intomore-itertools:masterfrom
rhettinger:derangements_doc
Sep 1, 2025
Merged

Clarify how derangements treats duplicate inputs#1069
bbayles merged 1 commit intomore-itertools:masterfrom
rhettinger:derangements_doc

Conversation

@rhettinger
Copy link
Copy Markdown
Contributor

With duplicate inputs, the output of derangements doesn't make sense. Given ['Alice', 'Bob', 'Bob'], the output includes ('Bob', 'Bob', 'Alice') which appears to violate the fixed-point invariant by leaving 'Bob' in the middle position.

Add text to explain what derangements is doing, a plausible rationale for its behavior, and practical advice for avoiding the issue.

@bbayles bbayles merged commit 58e0331 into more-itertools:master Sep 1, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants