Created
December 23, 2015 06:35
-
-
Save obiPlabon/7beb694664c97635e513 to your computer and use it in GitHub Desktop.
Matrix diagonal difference
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 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