From: "Matt Murphy" <mmmurf@gmail.com>
Date: July 13, 2007 12:10:35 PM CDT
To: submission@rubyquiz.com
Subject: please forward to ruby quiz submissionrequire 'set'
a = [-1, 2, 5, -1, 3, -2, 1]
min = 0
max = a.size - 1subs = Set.new
(min..max).each do |x|
(min..max).each do |y|
subs << a[x,y]
subs << a[y,x]
end
endputs subs.sort_by{|arr| arr.inject(0){|sum,element| element + sum } }.reverse.first.inspect
···
Begin forwarded message: