Created
September 6, 2013 20:54
-
-
Save kpuputti/6469911 to your computer and use it in GitHub Desktop.
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
// http://reaktor.fi/ura/fast_track/ | |
function find(input) { | |
'use strict'; | |
function toInt(s) { | |
return parseInt(s, 10); | |
} | |
function product(a, b) { | |
return a * b; | |
} | |
return _.range(0, input.length - 5) | |
.map(function (i) { | |
return input.slice(i, i + 5); | |
}).reduce(function (acc, curr) { | |
return Math.max(acc, curr.split('').map(toInt).reduce(product)); | |
}, -1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment