Skip to content

Instantly share code, notes, and snippets.

@lucascaton
Created November 10, 2014 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucascaton/f18d4dc426dd9da04439 to your computer and use it in GitHub Desktop.
Save lucascaton/f18d4dc426dd9da04439 to your computer and use it in GitHub Desktop.
a = [1, 2, 3, 4]
a.each_with_index.map do |element, index|
a.dup.delete_if { |e| e == a[index] }.inject(:*)
end
#=> [24, 12, 8, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment