04-25-2024, 11:19 PM
(This post was last modified: 04-26-2024, 01:56 AM by PhilOfPerth.)
(04-24-2024, 07:41 PM)SMcNeill Wrote: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.
Ahah! That's a (reasonably) simple solution to a problem I'm wrestling with at the moment! I had written a factorial-ising routine, but it was way too bulky and slow to be useful. I'll try to adapt this into my language ("dumb it down") and use it!
Edit: This worked when I used alpha chars, which is what I want) to do), but when I used anything longer than 7 characters, it gave no result.
Edit2: I was able to get results when I added this before the last Next, and remove the Print wordlist$(i)
Print wordlist(k);" ";
It's still very slow for more than 7 chars, but that may be enough (for mine, anyway). 87 sec for 8 characters.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Please visit my Website at: http://oldendayskids.blogspot.com/