A simple library that calculates all possible permutations (with repetition) from an iterator and a length.
Calculate the area for permutation computation.
iterable (Iterable): The iterable object.
length (int): The length for permutation computation.
int: The area for permutation computation.
Generate permutations of given iterable with specified length.
iterable (Iterable): The iterable object.
length (int): The length for permutation computation.
list: List of permutations of the given iterable with the specified length.
import pcomp
print("Area:", pcomp.area(range(2), 4)) # it returns: 16
print("Permutations with repetition:", pcomp.pc(range(2), 4)) # it returns: [[0, 0, 0, 0], [0, 0, 0, 1], ..., [1, 1, 1, 1]]
The area function returns the total number of possible permutations with repetition. And the pcomp function returns a list where each sublist represents one permutation.