const all_powers = [ "france", "prussia", "pragmatic", "austria", "bavaria", "saxony" ] all_powers.forEach((pow,idx) => { for (let type of [ "generals", "trains", "pieces" ]) { console.log("const all_" + pow + "_" + type + " = all_power_" + type + "[P_" + pow.toUpperCase() + "]") } }) const all_combos = [] for (let bit = 1; bit < 63; ++bit) { let combo = [] for (let i = 0; i < 6; ++i) if (bit & (1 << i)) combo.push(all_powers[i]) all_combos.push(combo) } for (let combo of all_combos) { let name = combo.join("_") console.log("const all_powers_" + name + " = [ " + combo.map(pow => "P_" + pow.toUpperCase()).join(", ") + " ]") if (combo.length > 1) for (let type of [ "generals", "trains", "pieces" ]) console.log("const all_" + name + "_" + type + " = [ " + combo.map(pow => "all_" + pow + "_" + type).join(", ") + " ].flat()") }