List of possible combinations for x numbers.

EdQas

Member
Licensed User
Hi everybody,
If I have 3 numbers, the list of all combinations is :
3*2*1 = 6 possibilities :
123 132 213 231 312 321

If I have 7 numbers, there are 5040 possibilities (7*6*5*4*3*2*1).

:sign0085: : how can i list all of these possibilities ?

Thank you for the help.

Ed
 

specci48

Well-Known Member
Licensed User
I think he is looking for something like this:

B4X:
Sub Globals
End Sub

Sub App_Start
    ' Create a Form1 and add a ListBox1
    FillListBox("1234567", "")
    Form1.Show
    Msgbox(ListBox1.Count)   
End Sub

Sub FillListBox(value, combi)
    If value = "" Then
        ListBox1.Add(combi)
    Else
        For i = 0 To StrLength(value) - 1
            FillListBox(StrRemove(value, i, 1), combi & SubString(value, i ,1))      
        Next
    End If
End Sub

specci48
 

EdQas

Member
Licensed User
Hurra !

Thank your Erel and Specci !
The example of Specci was what i was searching for. :sign0060:
Once more, many thanks.
Have a nice sunday.
Ed
 
Top