Possible Duplicate:
ruby - Permutation between elements of an array
I'm coding a plugin in Google Sketchup with ruby and I faced a real problem while trying to permute different elements in arrays that are present in an another array, all this depending on a user combination.
I have an array of arrays like:
[["a, "b", c"], ["lol1", "lol2", lol3"], ["so1", "so2", "so3"]]
For a combination like:
[1, 2, 3]
The output should still same:
[["a", "b", "c"], ["lol1", "lol2", "lol3"], ["so1", "so2", "so3"]]
But for a combination like:
[2, 1, 3]
The output should be:
[["b", "a", "c"], ["lol2", "lol1", "lol3"], ["so2", "so1", "so3"]]
But for a combination like:
[3, 2, 1]
The output should be:
[["c", "b", a"], ["lol3", "lol2", "lol1"], ["so3", "so2", "so1"]]
thearray.map do |row| row.map do row.delete_at(1) end endtwo times so I keep only the first and then do a push of the two strings. But it didn't work