I need to calculate permutations iteratively. The method signature looks like:
int[][] permute(int n)
For n = 3 for example, the r
n = 3
Is using 1.9's Array#permutation an option?
>> a = [0,1,2].permutation(3).to_a => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]