Handle repeated objects and arithmetic safely
Extend the model to repeated letters, circles, distributions, and exact calculations.
Understand the idea
Repeated indistinguishable letters divide a distinct arrangement count by each frequency factorial. Circular arrangements of distinct objects give (n − 1)! only when rotations are identified and reflections are still different. Stars and bars counts S identical objects in K labelled boxes as C(S + K − 1, K − 1) for K ≥ 1 and nonnegative contents.
Trace a small example
AAB has 3!/2! = 3 arrangements. Distributing 3 identical objects into 2 labelled boxes has 4 solutions: (0,3), (1,2), (2,1), (3,0). Lower bounds can be removed by assigning them first; upper bounds require excluding invalid assignments rather than ignoring them.
Conditions and cost
Exact integer division and division modulo M are different operations. Promote before multiplication and check intermediate bounds. For large exact combinations use proved cancellation; for small arbitrary-modulus counts Pascal addition is safer than dividing residues.
How many distinct rearrangements of AAB exist?
Turn the idea into code
Distribute 5 identical objects among 3 labelled boxes, with at least one in each.
Give me a hint
Put one in each box first, then distribute the remaining two.
Show the explained solution
The remaining nonnegative allocations number C(2 + 3 − 1, 3 − 1) = C(4, 2) = 6.
Your notes
Mark complete when you can explain it yourself.