aca tenes un ejemplo que es facil adaptarlo.
aclaro que si vos queres permutaciones de 6 y realizados con 10 numeros (del 0 al 9), eso daria un total de 10 mil millones de valores (10 elevado a la 10) si lo haces con valores que pueden repetirse.
pero si los haces con valores sin repeticion la cifra seria factorial de 10! o sea 3628800 de valores.
este ejemplo lo hace de la longitud que quieras pero sin repeticion.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim inputLine As String = "123"
Dim rec As New Recursion()
rec.InputSet = rec.MakeCharArray(inputLine)
rec.CalcPermutation(0)
Debug.WriteLine("# of Permutations: " + rec.PermutationCount.ToString)
End Sub
Class Recursion
Private elementLevel As Integer = -1
Private numberOfElements As Integer
Private permutationValue As Integer() = New Integer(-1) {}
Private m_inputSet As Char()
Public Property InputSet() As Char()
Get
Return m_inputSet
End Get
Set(ByVal value As Char())
m_inputSet = value
End Set
End Property
Private m_permutationCount As Integer = 0
Public Property PermutationCount() As Integer
Get
Return m_permutationCount
End Get
Set(ByVal value As Integer)
m_permutationCount = value
End Set
End Property
Public Function MakeCharArray(ByVal InputString As String) As Char()
Dim charString As Char() = InputString.ToCharArray()
Array.Resize(permutationValue, charString.Length)
numberOfElements = charString.Length
Return charString
End Function
Public Sub CalcPermutation(ByVal k As Integer)
elementLevel += 1
permutationValue.SetValue(elementLevel, k)
If elementLevel = numberOfElements Then
OutputPermutation(permutationValue)
Else
For i As Integer = 0 To numberOfElements - 1
If permutationValue(i) = 0 Then
CalcPermutation(i)
End If
Next
End If
elementLevel -= 1
permutationValue.SetValue(0, k)
End Sub
Private Sub OutputPermutation(ByVal value As Integer())
For Each i As Integer In value
Debug.Write(m_inputSet.GetValue(i - 1))
Next
Debug.WriteLine("")
PermutationCount += 1
End Sub
End Class
End Class
saludos.