Skip to content

Instantly share code, notes, and snippets.

@kpuputti
Created September 6, 2013 20:54
Show Gist options
  • Save kpuputti/6469911 to your computer and use it in GitHub Desktop.
Save kpuputti/6469911 to your computer and use it in GitHub Desktop.
// 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