Permutations: Difference between revisions

m
Line 7,376:
::<code>[ 3 1 0 2 ]</code>
::<code>[ 3 1 2 0 ]</code>
by stuffing the 30 into each of the 4 possible positions that it could go.
 
The code start with a nest of all the permutations of 0 items <code>[ [ ] ]</code>, and each time though the outer <code>times</code> loop (i.e. 4 times in the example) it takes each of the permutations generated so far (this is the <code>witheach</code> loop) and applies the central idea descried above (that is the inner <code>times</code> loop.)
1,480

edits