Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Created July 27, 2019 14:51
Show Gist options
  • Save manojnaidu619/134a1eedd00c9ebc461656e5776e1889 to your computer and use it in GitHub Desktop.
Save manojnaidu619/134a1eedd00c9ebc461656e5776e1889 to your computer and use it in GitHub Desktop.
Codechef solution for " Easy Math (prob code : RPD) " in Ruby
n = gets.to_i
count = []
a = []
n.times do
count << gets.to_i
s = gets.strip.split(/\s+/).map(&:to_i)
a << s
#p sum.max
end
a.each do |i|
sum = []
for x in 0..i.count do
for y in x+1...i.count do
sum << (i[x]*i[y]).to_s.split('').map{|e| e.to_i}.reduce(:+)
end
end
p sum.max
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment