Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Earth - Olga #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/hourglass.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

def hourglass(matrix)
raise NotImplementedError, "The matrix method has not been implemented yet!"
sum = 0
r = 0
c = 0
max_sum = -1.0/0.0
4.times do |r|
4.times do |c|
sum = matrix[r][c] + matrix[r][c + 1] + matrix[r][c + 2] + matrix[r + 1][c + 1] + matrix[r + 2][c] + matrix[r + 2][c + 1] + matrix[r + 2][c+ 2]
max_sum = sum if max_sum < sum
end
end
return max_sum
end