Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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