7 kyu
#1 Matrices : Making an Alternating Sum
440 of 994raulbc777
Description:
We have a matrix of integers with m rows and n columns.
We want to calculate the total sum for the matrix:
As you can see, the name "alternating sum" of the title is due to the sign of the terms that changes from one term to its contiguous one and so on.
Let's see an example:
matrix = [[1, 2, 3], [-3, -2, 1], [3, - 1, 2]]
total_sum = (1 - 2 + 3) + [-(-3) + (-2) - 1] + [3 - (-1) + 2] = 2 + 0 + 6 = 8
You may be given matrixes with their dimensions between these values:10 < m < 300
and 10 < n < 300
.
More example cases in the Example Test Cases. Enjoy it!!
Fundamentals
Data Structures
Algorithms
Mathematics
Logic
Matrix
Similar Kata:
Stats:
Created | Apr 27, 2016 |
Published | Apr 27, 2016 |
Warriors Trained | 1851 |
Total Skips | 42 |
Total Code Submissions | 2666 |
Total Times Completed | 994 |
Python Completions | 440 |
JavaScript Completions | 453 |
Ruby Completions | 61 |
C Completions | 85 |
Julia Completions | 11 |
Total Stars | 37 |
% of votes with a positive feedback rating | 87% of 203 |
Total "Very Satisfied" Votes | 161 |
Total "Somewhat Satisfied" Votes | 33 |
Total "Not Satisfied" Votes | 9 |