mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Rename var
This commit is contained in:
parent
dcfdf73a7f
commit
a285989e1c
1 changed files with 4 additions and 4 deletions
|
@ -7,19 +7,19 @@
|
|||
|
||||
#
|
||||
# 1. Brute force solution
|
||||
#
|
||||
#
|
||||
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 |num2, 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
|
||||
|
||||
products_other_elements
|
||||
product_of_other_elements
|
||||
end
|
||||
|
||||
puts(calculate_products_of_all_other_elements([1, 2, 3]))
|
||||
|
|
Loading…
Reference in a new issue