B4A Library Permutation - Get all Permutations of a String

Permutation
Version:
1
  • Permutation
    Methods:
    • permute (s As String) As List


B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim perm As Permutation
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    'Log(perm.permute("ABC"))
    Dim l As List = perm.permute("ABC")
    For i = 0 To l.Size -1
        Log(l.Get(i))
    Next
End Sub
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
BCA
BAC
CBA
ABC
ACB
CAB
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **

There is an B4J version as well.
 

Attachments

  • PermutationEx.zip
    6.6 KB · Views: 306
  • libPermutationV1.0.0.zip
    2.1 KB · Views: 348
Last edited:
Top