Skip to content

Instantly share code, notes, and snippets.

@asimpletune
Created August 4, 2015 06:41
Show Gist options
  • Save asimpletune/e3ba4c56e31df50e10a3 to your computer and use it in GitHub Desktop.
Save asimpletune/e3ba4c56e31df50e10a3 to your computer and use it in GitHub Desktop.
Absolute Diagonal Difference
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