Skip to content

Instantly share code, notes, and snippets.

@edenthecat
Last active December 9, 2015 20:03
Show Gist options
  • Save edenthecat/f14d384ecdc49178783b to your computer and use it in GitHub Desktop.
Save edenthecat/f14d384ecdc49178783b to your computer and use it in GitHub Desktop.
def findHighestProduct(list_of_ints)
for i in 0...list_of_ints.length
list_of_ints[i] = list_of_ints[i].abs
end
puts list_of_ints.to_s
list_of_ints.sort!.reverse!
max_product = list_of_ints[0] * list_of_ints[1] * list_of_ints[2]
puts max_product
end
findHighestProduct([1, 8, 3, 5, 9, 12, -100])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment