[Tutor] A small math puzzle [recreational Python]

Tim Peters tim.one@home.com
Sat, 5 Jan 2002 22:18:04 -0500


[talking about derangements of words with duplicate letters]

FYI, you can compute this without exhaustive generation, but it's not
simple.  See, e.g., section 4-7 (Permutations with Forbidden Positions) in
Liu's "Introduction to Combinatorial Mathematics".  That section is at the
end of the chapter on the principle of inclusion and exclusion, and builds
on everything before it, so it's not easy to summarize.  I expect it's
substantially easier to write a program to generate all possibilities!