this is the permutation code in VB
Public Sub Permutate( _
ByVal ArrayCount As Long, _
ByRef Elements() As Long, _
ByRef Order() As Long, _
ByRef Orders As Collection)
End Sub
Public Sub Permutate( _
ByVal ArrayCount As Long, _
ByRef Elements() As Long, _
ByRef Order() As Long, _
ByRef Orders As Collection)
Dim Position As Long
Dim Element As Long
Dim i As Long
Dim ArrayLen As Long
' The length of the Elements array. We need this
' for our calculations later on.
ArrayLen = (UBound(Elements) - LBound(Elements) + 1)
' Position in the Order array of the first element in
' the permutated arrays.
'
' Example: Given the array(a,b,c,d), where we want to permutate
' (b,c,d), the position in the new array for the first element
' will be 2 (since (a) will take up the first position).
' Likewise, when we permutate (c,d), the position of the first
' element will be 3, since the first two spots are taken by
' (a,b).
Position = ArrayCount - ArrayLen + 1
If ArrayLen = 1 Then
' The most primitive array we will permutate.
' The result is the array itself, and the result
' is inserted in the last position of the Order array.
Order(Position) = Elements(LBound(Elements))
' This Order is now complete, since the final element has
' been filled in.
Orders.Add Order
Else
' The permutation of Elements is each distinct Element
' + all permutations of the remaining elements.
For i = LBound(Elements) To UBound(Elements)
Element = Elements(i)
Order(Position) = Element
Permutate ArrayCount, RemoveFromArray(Elements, Element),
Order, Orders
Next i
End If
End Sub
Public Function RemoveFromArray(ByRef Elements() As Long, ByVal
Element As Long) As Long()
Dim NewArray() As Long
Dim i As Long
Dim newi As Long
' Will create a new array where Element has been left out.
ReDim NewArray(LBound(Elements) To UBound(Elements) - 1)
For i = LBound(Elements) To UBound(Elements)
If Elements(i) <> Element Then
newi = newi + 1
NewArray(newi) = Elements(i)
End If
Next
RemoveFromArray = NewArray
End Function
--- In [email protected], "Mischa Kroon"
<[EMAIL PROTECTED]> wrote:
> The vb code is probably easily converted to vbscript.
>
> If you paste the vb code into a mail we will probably be able to
adept it
> for you to work with vbscript.
>
> ----- Original Message -----
> From: "Cady" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Thursday, July 28, 2005 9:39 PM
> Subject: [AspClassicAnyQuestionIsOk] Permutation question?
>
>
> > hi all, i need some help about permutation in ASP
> >
> > if user input 4 digit.
> > n=1234
> >
> > how do i make this n!
> > so the result would be like this
> >
> > 1234
> > 1243
> > 1324
> > 1342
> > and etc 24x i found some forums about this, but all in VB , i
need it
> > in ASP
> >
> > thank you for the help
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hinp26g/M=362131.6882499.7825260.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1122728972/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/