嗨,我是 Fly,用 Ruby 寫 Chatbot 並挑戰30天分享心得
為確保不會沒靈感
每日含 Ruby 解題增加內容
https://www.hackerrank.com/domains/tutorials/30-days-of-code
arr = Array.new(6)
sum = []
6.times do |i|
arr[i] = gets.rstrip.split(' ').map(&:to_i)
end
arr.each_with_index do |x, i|
x.each_with_index do |y, j|
sum << arr[i][j]+arr[i][j+1]+arr[i][j+2]+arr[i+1][j+1]+arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2] if (i < 4 && j < 4)
end
end
p sum.max