• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Formula for listing all 3 digit combinations out of 6 digits

Dear Experts,

I need formula for listing all 3 digit combinations out of 5/6 digits numbers without repetitions

For example - 124058 [6 digits]
3 digits are
124,120,125,128,240,245,248,405,408,580,145,148,105,108,158

For example -12405 [5 digits]
3 digits are
124,120,125,240,245,140,145,105,405

Request your support please!
 
One possibility:
Code:
=LET(
   v, 124058,
   c, 3,
   n, LEN(v),
   p, MOD(TRUNC(SEQUENCE(n^c,,0)/n^(c-SEQUENCE(,c))),n)+1,
   a, UNIQUE(BYROW(p,LAMBDA(r,CONCAT(MID(v,SORT(r,,,1),1),"|",COLUMNS(UNIQUE(r,1))=c)))),
   TEXTBEFORE(FILTER(a,TEXTAFTER(a,"|")),"|")
)

Alternatively, some basic Python code:
Python:
import itertools as it

comb = it.combinations("124058", 3)

list(comb)

See attached for more examples...
 

Attachments

  • COMBIN_PY_vs_LET.xlsx
    11.9 KB · Views: 1
Back
Top