Skip to content

Instantly share code, notes, and snippets.

@seseg-rj
Created February 10, 2014 22:42
Show Gist options
  • Save seseg-rj/8925752 to your computer and use it in GitHub Desktop.
Save seseg-rj/8925752 to your computer and use it in GitHub Desktop.
Problema proposto:
https://codility.com/demo/results/demoSBAPTX-M95/
Solução do DOJO:
def solution(*a)
curr = 1
great = []
a.combination(3) do |c|
c.each{ |i| curr *= i}
great << curr
curr = 1
end
great.sort[great.length() -1]
end
puts (solution 2,7,1,-3) == 14
Solução do Vagner:
a.combination(3).map { |c| c.inject(😗) }.max
@fbazzarella
Copy link

  • c.inject(:*)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment