Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Created December 23, 2015 06:35
Show Gist options
  • Select an option

  • Save obiPlabon/7beb694664c97635e513 to your computer and use it in GitHub Desktop.

Select an option

Save obiPlabon/7beb694664c97635e513 to your computer and use it in GitHub Desktop.
Matrix diagonal difference
function matrixDiagDiff(m) {
var d1 = d2 = 0;
for(var i = 0, l = m.length; i < l; i++){
d1 += m[i][i];
d2 += m[i][l-(i+1)];
}
console.log(d1-d2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment