Skip to content

Instantly share code, notes, and snippets.

@Underdoge
Created February 25, 2017 22:36
Show Gist options
  • Save Underdoge/477910378659a98b68dbe6dd9c601be1 to your computer and use it in GitHub Desktop.
Save Underdoge/477910378659a98b68dbe6dd9c601be1 to your computer and use it in GitHub Desktop.
matrixElementsSum
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