Created
August 4, 2015 06:41
-
-
Save asimpletune/e3ba4c56e31df50e10a3 to your computer and use it in GitHub Desktop.
Absolute Diagonal Difference
This file contains 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 processData(input) { | |
var tokenized = input.split("\n").slice(1).map(function(current) { return current.split(/\s/); }), count = 0; | |
var l2R = tokenized.reduce(function(total, current) { return Number(total) + Number(current[count++]); }, 0); | |
var r2L = tokenized.reduce(function(total, current) { return Number(total) + Number(current[--count]); }, 0); | |
console.log(Math.abs(l2R -r2L)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment