Skip to content

Instantly share code, notes, and snippets.

@eveadele
Created April 17, 2014 19:36
Show Gist options
  • Save eveadele/11006846 to your computer and use it in GitHub Desktop.
Save eveadele/11006846 to your computer and use it in GitHub Desktop.
Array permutations
array1 = ['a', 'b', 'c']
array2 = ['d', 'e', 'f']
array3 = ['g', 'h', 'i']
permutations = []
array1.each do |a1|
array2.each do |a2|
array3.each do |a3|
permutations << [a1, a2, a3]
end
end
end
permutations.each do |perm|
print perm
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment