A permutation with replacement counts ordered selections when each chosen item returns to the set before the next selection. Because every position retains the same number of choices, n options selected across r positions produce n^r possible arrangements. section 2.2.3
Use the following distinctions when selecting a counting method:
- Treat order as significant: 3-7-4 differs from 4-7-3. section 2.2.3
- Allow repetition: a sequence such as 3-3-4 remains valid because each digit is replaced after selection. section 2.2.3
- Compare with permutations without replacement, where each selection reduces the number of available choices. section 2.2.3 section 2.5
Counting arrangements in Python
For n = 5 options and r = 3 positions, calculate 5^3 = 125 arrangements. Python expresses the same calculation with either exponentiation or pow(n, r). section 2.2.3
>>> num_permutations = n ** r
>>> print(f'Number of permutations with replacement: {num_permutations}')
Number of permutations with replacement: 125
Inspect the Python listing showing n ** r and its output of 125 for five options selected across three positions. section 2.2.3

