Skip to content

Instantly share code, notes, and snippets.

@EricDykstra
Created December 24, 2015 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricDykstra/fa2d76059650abfcba08 to your computer and use it in GitHub Desktop.
Save EricDykstra/fa2d76059650abfcba08 to your computer and use it in GitHub Desktop.
# uncomment for part 1 num_groups = 3
# uncomment for part 2 num_groups = 4
start = 1
until answer = array.combination(start).select{|c| c.inject(:+) == (array.inject(:+) / num_groups)}.sort_by{|c| c.inject(:*)}.first
start += 1
end
p answer.inject(:*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment