Учитывая объект с n клавишами, нужно найти все комбинации каждых 3 клавиш ( nC3 в математике)
это самый эффективный способ?
var x = {}; // object
x['00'] = [1, 7, 9];
x['01'] = [1, 9];
x['02'] = [6, 8];
x['03'] = [1, 7];
x['04'] = [1, 5, 8];
x['05'] = [4, 6, 8, 9];
var triples = [],
c = [0,0,0]; // counter. keep track of the indexes when looping over objects
for(var i in x){
c[0]++;
c[1] = 0;
for(var j in x){ // loop to compare this x[i] array to all other arrays
c[1]++;
if( c[1] < c[0]+1 ) continue;
c[2] = 0;
for(var k in x){
c[2]++;
if( c[2] < c[1]+1 ) continue;
triples.push( [i,j,k] );
}
}
}
console.dir(triples);