Skip to content

Instantly share code, notes, and snippets.

@edenthecat
Created December 9, 2015 19:53
Show Gist options
  • Save edenthecat/79deba603e23b97c826b to your computer and use it in GitHub Desktop.
Save edenthecat/79deba603e23b97c826b to your computer and use it in GitHub Desktop.
def getProductsOfAllIntsExceptAtIndex(someIntegers)
products = []
for i in 0...someIntegers.length
integersWithoutIndex = someIntegers.dup
integersWithoutIndex.delete_at(i)
product = 1
for j in integersWithoutIndex
product *= j
end
products.push(product)
end
puts products.to_s
end
getProductsOfAllIntsExceptAtIndex([1, 7, 3, 4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment