2 ms·
The questions ask for all permutations of length 3. What you've described is the Cartesian product: import itertools print(len([x for x in itertools.p
by joshvm 8y ago
The questions ask for all permutations of length 3. What you've described is the Cartesian product:
import itertools
print(len([x for x in itertools.product(range(10), repeat=3)])) #1000
print(len([x for x in itertools.permutations(range(10), 3)])) #720
itertools.product essentially does a nested for loop.
The reason it's less is because each number has to be different, so you can't have 000 or 111, etc.