1234
5678
1258
1358
1458
const numbers = [1, 2, 3, 4, 5, 6, 7, 8];
let c = 0;
numbers.forEach(i1 => {
numbers.forEach(i2 => {
numbers.forEach(i3 => {
numbers.forEach(i4 => {
const uniqueNumbers = [...new Set([i1, i2, i3, i4])];
if (uniqueNumbers.length === 4) {
console.log(uniqueNumbers);
c++;
}
})
})
})
});
console.log(c);
>>> import itertools
>>> four_numbers_combinations = list(itertools.permutations(eight_numbers_list, 4))
>>> len(four_numbers_combinations)
1680
>>> four_numbers_combinations[:10]
[(1, 2, 3, 4), (1, 2, 3, 5), (1, 2, 3, 6), (1, 2, 3, 7), (1, 2, 3, 8), (1, 2, 4, 3), (1, 2, 4, 5), (1, 2, 4, 6), (1, 2, 4, 7), (1, 2, 4, 8)]