Auf diese Weise lässt sich überprüfen, ob a eine Permutation von b ist.
http://de.wikipedia.org/wiki/Permutation
Function is_perm(ByVal a As String, ByVal b As String) As Boolean
If a.Length <> b.Length Then Return False
Dim ax, bx As Byte
For Each c In a
ax += CByte(Val(c))
Next
For Each c In b
bx += CByte(Val(c))
Next
If ax <> bx Then Return False
Dim al, bl As New ArrayList
For Each c In a
al.Add(c)
Next
al.Sort()
For Each c In b
bl.Add(c)
Next
bl.Sort()
For x As Byte = 0 To al.Count - 1
If al(x) <> bl(x) Then Return False
Next
Return True
End Function
6 Kommentare zum Snippet