Last active
March 4, 2018 13:09
-
-
Save io-developer/fa9b063df1c621e44370439eb2e7dc41 to your computer and use it in GitHub Desktop.
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 calc(input) { | |
var checksum = 0; | |
input.split('\n').forEach(row => { | |
var nums = row.split('\t').map(n => parseInt(n)); | |
var min = nums.reduce((a, b) => Math.min(a, b)); | |
var max = nums.reduce((a, b) => Math.max(a, b)); | |
checksum += max - min; | |
}); | |
return checksum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment