Rename var

This commit is contained in:
Vitor Oliveira 2020-12-19 20:23:48 -08:00
parent dcfdf73a7f
commit a285989e1c

View file

@ -9,17 +9,17 @@
# 1. Brute force solution # 1. Brute force solution
# #
def calculate_products_of_all_other_elements(nums) def calculate_products_of_all_other_elements(nums)
products_other_elements = Array.new(nums.length, 1) product_of_other_elements = Array.new(nums.length, 1)
nums.each_with_index do |num1, i| nums.each_with_index do |num1, i|
nums.each_with_index do |num2, j| nums.each_with_index do |num2, j|
if (i != j) if (i != j)
products_other_elements[i] = products_other_elements[i] * num2 product_of_other_elements[i] = product_of_other_elements[i] * num2
end end
end end
end end
products_other_elements product_of_other_elements
end end
puts(calculate_products_of_all_other_elements([1, 2, 3])) puts(calculate_products_of_all_other_elements([1, 2, 3]))