|
|
|
|
|
by drc0
3295 days ago
|
|
hints! function combRep(arr, l) {
if (l === void 0) l = arr.length; // Length of the combinations
var data = Array(l), // Used to store state
results = [
]; // Array of results
(function f(pos, start) { // Recursive function
if (pos === l) { // End reached
results.push(data.slice()); // Add a copy of data to results
return;
}
for (var i = start; i < arr.length; ++i) {
data[pos] = arr[i]; // Update data
f(pos + 1, i); // Call f recursively
}
}) (0, 0); // Start at index 0
return results; // Return results
}
var parents = [];
for(b in bases.base) {
if (bases.base[b].parents != undefined) {
for (p of bases.base[b].parents) {
parents[p.sort().join('-')] = b;
}
}
}
function gethints() {
combinations = combRep([1, 2, 3, 4].concat(game.progress), 2);
for (c of combinations) {
let idx = c.sort().join('-');
if (parents[idx] != undefined && game.progress.find((e, i, a) => parents[idx] == e) == undefined) {
console.log(bases.names[c[0]], bases.names[c[1]]);
}
}
}
|
|