mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-27 21:58:57 +01:00
Rename var
This commit is contained in:
parent
dcfdf73a7f
commit
a285989e1c
1 changed files with 4 additions and 4 deletions
|
@ -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]))
|
||||||
|
|
Loading…
Reference in a new issue