shaowu459

Excel Formula: An easy way to get all combinations of items in different columns

shaowu459

Well-known Member
Joined
Apr 26, 2018
Messages
691
Office Version
  1. 365
Platform
  1. Windows

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Do you mean to list the contents of the string “A-UP-1” in three cells, such as A1="A", B1="UP", and C1="1"

yes that's what i want
sorry
but do not know how to reply to your reaccrion

thx

Jelle
 
Do you mean to list the contents of the string “A-UP-1” in three cells, such as A1="A", B1="UP", and C1="1"

yes that's what i want
sorry
but do not know how to reply to your reaccrion

thx

Jelle
it is possible, i write the formula before, i will check it tomorrow.
 
thx

Jelle
for your reference, however, if you have a large dataset, i'm not sure whether the efficiency is acceptable.
Book.xlsx
ABCDEFGHIJ
1ADFOADFO
2BEGADGO
3CHADHO
4IADIO
5AEFO
6AEGO
7AEHO
8AEIO
9BDFO
10BDGO
11BDHO
12BDIO
13BEFO
14BEGO
15BEHO
16BEIO
17CDFO
18CDGO
19CDHO
20CDIO
21CEFO
22CEGO
23CEHO
24CEIO
25
Sheet1
Cell Formulas
RangeFormula
F1:I24F1=REDUCE(A1:A3,B1:D1,LAMBDA(x,y,LET(s,TOCOL(OFFSET(y,,,99),1),DROP(REDUCE(0,SEQUENCE(ROWS(x)),LAMBDA(m,n,LET(t,INDEX(x,n,),VSTACK(m,IFNA(HSTACK(t,s),t))))),1))))
Dynamic array formulas.
 
Book.xlsx
ABCDEFGHIJ
1ADFOADFO
2BEGADGO
3CHADHO
4IADIO
5AEFO
6AEGO
7AEHO
8AEIO
9BDFO
10BDGO
11BDHO
12BDIO
13BEFO
14BEGO
15BEHO
16BEIO
17CDFO
18CDGO
19CDHO
20CDIO
21CEFO
22CEGO
23CEHO
24CEIO
25
Sheet1
Cell Formulas
RangeFormula
F1:I24F1=REDUCE(A1:A3,B1:D1,LAMBDA(x,y,DROP(REDUCE(0,SEQUENCE(ROWS(x)),LAMBDA(m,n,LET(t,INDEX(x,n,),VSTACK(m,IFNA(HSTACK(t,TOCOL(OFFSET(y,,,99),1)),t))))),1)))
Dynamic array formulas.
 
thx a lot
i need this for solving binairo/takuzu puzzle
to test for solution i have manipulate each combination further
Now on short holiday so next week i will continue

if memory/speed is a problem than i will fall back on using mixed radix system for generating combinations
I am amazed, after having used excel in the past , about dynamic arrays, lamnda, let statement
is for me as die hard programming in Fortran, Pscal, Algol,Ada,Python etc a learning curve to be able to understand your very nice piece of code
thanks a lot

Jelle
 
Thank you for your response. Wishing you a pleasant vacation. In Office 365, lambda functions can be used by defining a name and then solving some classic problems using recursion, such as the Hanoi Tower problem. Here is the recursive formula that I have written before to solve the Hanoi Tower problem for your reference:
Screenshot_20230826_065255.jpg
Screenshot_20230826_065229.jpg
 
I think both the Binairo/Takuzu puzzle and Sudoku problems can be solved using a recursive method. However, I have never tried it in Excel. Through my testing in Excel, there is a certain limit on the depth of loops for recursion, and efficiency becomes an issue when dealing with large amounts of data, far worse than other real programming languages. Another issue is that Excel can only handle up to one million rows, and problems like m-n or n-permutations of n numbers easily result in results exceeding one million rows.
 

Forum statistics

Threads
1,216,499
Messages
6,131,012
Members
449,613
Latest member
MedDash99

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top