Created
February 25, 2017 22:36
-
-
Save Underdoge/477910378659a98b68dbe6dd9c601be1 to your computer and use it in GitHub Desktop.
matrixElementsSum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function matrixElementsSum(matrix) { | |
price=0; | |
for(var y=0;y<matrix.length;y++) | |
for(var x=0;x<matrix[0].length;x++){ | |
if(y==0) | |
price+=matrix[y][x]; | |
else{ | |
if(matrix[y-1][x]==0) | |
matrix[y][x]=0; | |
price+=matrix[y][x]; | |
} | |
} | |
return price; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment