UNPKG

battleship-search

Version:

maximize an n-dimensional landscape using the battleship search algorithm

12 lines (10 loc) 302 B
var gray = require('gray-code'); module.exports = function (ranges) { var bounds = [ [ ranges[0][0] ], [ ranges[0][1] ] ]; var indexes = gray(ranges.length); return indexes.map(function (ix) { return ix.map(function (i, j) { return ranges[j][i]; }); }); };