Print combinations possible javascript

0

I made the code to create arrays with the possible combinations for a system I'm developing, but what happens is that if a number of combinations exceeds the memory, I want to know if I can not separate this code in parts or if you have some way of printing everything, here is the code below

function combine(a, q){
    var n = a.length - 1, l = n - q + 1, x = 0, c = [], z = -1, p, j, d, i;
    if(q > n || q < 2) return c;
    for(p = [], i = q; p[--i] = i;);
    while(x <= l){
        for(c[++z] = [], j = -1; ++j < q; c[z][j] = a[p[j]]);
        if(++p[j - 1] > n)
            while(j--)
                if(!j && x++, (d = p[j]) < l + j){
                    while(j < q) p[j++] = ++d;
                    break;
                }
    }
    return c;
    };
    var a = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17","18","19","20","21","22","23","24","25"], 
    q = 20, j = combine(a, q);
    document.write(
    "<h2>", a.join(" - "), " : ", q, " = ", j.length, "</h2>",
    j.join("<br>")
    );
    
asked by anonymous 16.07.2018 / 17:10

0 answers