Skip to content

Tag: combinatorics

All tuples of positive integers

How do I create a generator that will return tuples of all combinations of positive integers, example for generating triplets. Answer This code uses a similar approach to Paul Hankin’s, but it’s more general since it will generate tuples of any desired width, not just 3. output The algorithm for c…