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

Chantelle | Edges | Matrix_Check_Sum #27

Open
wants to merge 2 commits 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
36 changes: 35 additions & 1 deletion lib/matrix_check_sum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
# whether the sum of each row matches the sum of corresponding column i.e. sum
# of numbers in row i is the same as the sum of numbers in column i for i = 0 to row.length-1
# If this is the case, return true. Otherwise, return false.

require 'pry'
def matrix_check_sum(matrix)
raise NotImplementedError
i = 0
matrix_len = matrix.length #rows

matrix_len.times do

c_sum = 0
r_sum = 0
j = 0

row_len = matrix[i].length

row_len.times do


if matrix[j][i] != nil
c_sum += matrix[j][i]
end

if matrix[i][j] != nil
r_sum += matrix[i][j]
end

j+= 1
end

if c_sum != r_sum
return false
end

i += 1
end

return true
end