Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to reorder string variable x factorial different ways?
#5
Code: (Select All)
ReDim Shared WordList(0) As String
FactorIt "1234", ""
For i = 1 To UBound(WordList)
    Print WordList(i),
Next

Sub FactorIt (word$, seed$)
    For i = 1 To Len(word$)
        seed1$ = seed$ + Mid$(word$, i, 1)
        w$ = Left$(word$, i - 1) + Mid$(word$, i + 1)
        For k = 1 To UBound(WordList)
            If WordList(k) = seed1$ + w$ Then Exit For
        Next
        If k > UBound(WordList) Then
            ReDim _Preserve WordList(k) As String
            WordList(k) = seed1$ + w$
        End If
        FactorIt w$, seed1$
    Next
End Sub

FactorIt above generates a list of values, removing duplicates for you.   For example, "goo" has two "o"s, so it can only generate "goo", "ogo", "oog", and a few of those in duplicate which we don't count.
Reply


Messages In This Thread
RE: How to reorder string variable x factorial different ways? - by SMcNeill - 04-24-2024, 07:41 PM



Users browsing this thread: 2 Guest(s)