yield_all_compositions_of_integer

mathtools.yield_all_compositions_of_integer(n)

Yields all compositions of positive integer n in descending lex order:

>>> for integer_composition in mathtools.yield_all_compositions_of_integer(5):
...     integer_composition
...
(5,)
(4, 1)
(3, 2)
(3, 1, 1)
(2, 3)
(2, 2, 1)
(2, 1, 2)
(2, 1, 1, 1)
(1, 4)
(1, 3, 1)
(1, 2, 2)
(1, 2, 1, 1)
(1, 1, 3)
(1, 1, 2, 1)
(1, 1, 1, 2)
(1, 1, 1, 1, 1)

Integer compositions are ordered integer partitions.

Returns generator of positive integer tuples of length at least 1.