[Solved] Iterate through every permutation of an array of numbers
Technically, a permutation means a re-ordering of some elements, so for example, [3,1,2] is a permutation of [1,2,3]. What you’re asking for is equivalent to iterating over a Cartesian product, hence the Python function being named product. As you correctly note, recursion is the way to go here. This is because generating all sequences for … Read more