Created
September 22, 2008 19:27
-
-
Save bmaland/12112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max_discount(prices) | |
prices = prices.sort.reverse | |
discount = 0 | |
while prices != [] | |
discount += prices[0..2].min | |
prices = prices[3..-1] | |
end | |
discount | |
end | |
gets.to_i.times do | |
gets | |
puts max_discount gets.split(" ").map(&:to_i) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment