Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Looping permutations

46 views
Skip to first unread message

Patrick McCarthy

unread,
Dec 1, 1999, 3:00:00 AM12/1/99
to
I need to log every permutation of a character set by using a loop

the len can be 1 to 5

and the character set is a to j


anyone good at loops out there

George Shears

unread,
Dec 1, 1999, 3:00:00 AM12/1/99
to

Willing to Try SQL???

table: tblAlphas, Field Alpha (Text)
10 Rows, each row has 1 character: a ... j

For 5:

SELECT a1.Alpha & a2.Alpha & a3.Alpha & a4.Alpha & a5.Alpha AS
Permutation
FROM tblAlphas AS a1, tblAlphas AS a2, tblAlphas AS a3, tblAlphas AS
a4, tblAlphas AS a5
WHERE ((a1.Alpha<>a2.Alpha And a1.Alpha<>a3.Alpha And
a1.Alpha<>a4.Alpha And a1.Alpha<>a5.Alpha) AND (a2.Alpha<>a3.Alpha
And a2.Alpha<>a4.Alpha And a2.Alpha<>a5.Alpha) AND
(a3.Alpha<>a4.Alpha And a3.Alpha<>a5.Alpha) AND
(a4.Alpha<>a5.Alpha))
ORDER BY a1.Alpha, a2.Alpha, a3.Alpha, a4.Alpha, a5.Alpha;

Or maybe I'm really not sure what you need to sdo.

George

Patrick McCarthy <pzm9...@glaxowellcome.co.uk> wrote in message
news:01bf3bf2$9086eff0$0c13c18f@ukd21986...

Marshall Barton

unread,
Dec 1, 1999, 3:00:00 AM12/1/99
to
Well, if I understand the question, maybe something like this will get you
started:

Sub Permute(Partial As String, Alpha As String, MaxLen As Integer)
Dim i As Integer, result As String
For i = 1 To Len(Alpha)
result = Partial & Mid(Alpha, i, 1)
Debug.Print result
If Len(result) < MaxLen Then
Permute result, Left(Alpha, i - 1) & Mid(Alpha, i + 1), MaxLen
End If
Next i
End Sub

In the Debug window, call it this way:
Permute "", "abcdefghij", 5

This will produce more than a half million strings so you may want to test
with a shorter character set and a lower len.

Good luck,
Marsh


Patrick McCarthy wrote in message <01bf3bf2$9086eff0$0c13c18f@ukd21986>...


>I need to log every permutation of a character set by using a loop
>
>the len can be 1 to 5
>
>and the character set is a to j
>
>
>anyone good at loops out there


-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----

0 new messages