Skip to content

Instantly share code, notes, and snippets.

@dpsk
Created September 23, 2011 08:25
Show Gist options
  • Save dpsk/1236955 to your computer and use it in GitHub Desktop.
Save dpsk/1236955 to your computer and use it in GitHub Desktop.
total_peoples = 0
puts "how much groups?"
groups = gets.chomp.to_i
majority_of_each_group = Array.new
groups.times do
puts "how much people in group?"
peoples = gets.chomp.to_i
majority_of_each_group << peoples/2 + 1
end
majority_of_each_group.sort[0..groups/2].each { |gp| total_peoples += gp }
puts "You need just a #{total_peoples} for win those votes!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment