Forum Discussion
davidleal
Apr 04, 2023Iron Contributor
Efficient approach to generate list of combinations with no repetition
I am trying to find the best way to generate the combination with no repetition, i.e. the corresponding set related to the total of a combination of COMBIN(n,m) output. I found several approaches wit...
- Apr 04, 2023
Forgive me for asking, but have I got the wrong end of the stick here?
= IF(Combinationsλ(n,m), "●","-") Combinationsλ = LET( k, 2 ^ SEQUENCE(1, n, 0), h, SEQUENCE(2 ^ n), p, SIGN(BITAND(h, k)), f, BYROW(p, LAMBDA(p, SUM(p))) = m, FILTER(p, f) )
davidleal
Apr 04, 2023Iron Contributor
Thanks, Peter, which test did you perform? which formula?, per my understanding, the version I posted based on your solution using MMULT is the fastest one, so I am going to accept your initial solution.
Patrick2788
Apr 04, 2023Silver Contributor
MMULT is suprisingly very efficient. I've seen the limit quoted as an output of 5,460 elements for Excel 2007 and earlier. The 365 limit appears to be much greater (or limited by available memory).
- The MMULT function returns #VALUE! if the output exceeds 5460 cells.
Description of the limitations for working with arrays in Excel - Office | Microsoft Learn
The most I've been able to output is 9 million elements:
=LET(n,3000,r,SEQUENCE(n),c,SEQUENCE(,n),MMULT(r,c))