Skip to content

Instantly share code, notes, and snippets.

@nikcorg
Last active December 22, 2015 05:49
Show Gist options
  • Save nikcorg/6426677 to your computer and use it in GitHub Desktop.
Save nikcorg/6426677 to your computer and use it in GitHub Desktop.
My solution to the problem at http://reaktor.fi/ura/fast_track/
function (input) {
return [].reduce.call(input, function (mem, n, i) {
return mem[i % 5] = n, mem.push(Math.max(mem.pop(), eval(mem.join("*")))), mem;
}, [0, 0, 0, 0, 0, 0]).pop();
}
function (input) {
return [].reduce.call(input, function (max, n, i, seq) {
return Math.max(max, eval([].slice.call(seq, i, i + 5).join("*")));
}, 0);
}
function (input) {
return _.reduce(input, function (max, n, i, seq) {
return Math.max(max, eval(_.head(_.tail(seq, i), 5).join("*")));
}, 0);
}
function (input) {
return _.max(_.map(input, function (n, i, seq) {
return eval(_.head(_.tail(seq, i), 5).join("*"));
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment