Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Billenium Transitions Xtra v1.3
Ceiling and Floor
Flash sending messages to Director
Special Edition Using Macromedia Director 8.5
Print Dialog Behavior
Change the Pattern of a Shape Sprite
Animation on MouseUp
Multi Cropper
ProMix
Vector Shape - Create Sine Wave
MediaMacros Xtras Mall
 

 

 

Behavior Get all combinations of a string

Added on 5/29/2003

 

Compatibilities:
D7 D8 D8_5 D9 Mac PC Shockwave

This item has not yet been rated

Author: MediaMacros (website)

Generates a list of possible combos for a given string. Limit can be set on minimum word length. Version 1.1 adds speed improvements for duplicates --adds min and max characters

on getAllCombos whatText, minChars, maxChars
if maxChars = void then maxChars = the maxInteger
if minChars = void then minChars = the maxInteger
--create a list of characters
charList = []
repeat with x = 1 to whatText.char.count
   charList.add(whatText.char[x])  
end repeat
sort charList
--create an empty list of words...
wordList = []
--start with an empty string
baseString = ""
--find all combos
createAllCombos(baseString, charList, wordList, minChars, maxChars)  
--sort it
-- sort(wordList)
return wordList
end

on createAllCombos baseString, charList, wordList, minChars, maxChars
--use each letter
if baseString.char.count < maxChars then
    c = ""
   repeat with x = 1 to charList.count
     --if its the same as the last letter we will get duplicates so skip it
     if c = charList[x] then next repeat
     c = charList[x]  
     --get the new string
     newString = baseString & c
     --add the current combo
     if newString.char.count >= minChars then wordList.append(newString, wordlist.count)
     --find the new words with recursion -- use a duplicate as lists are referenced
     newCharList = charList.duplicate()
     newCharList.deleteAt(x)
     if newCharList.count > 0 then
       createAllCombos(newString, newCharList, wordList, minChars, maxChars)
     end if
   end repeat
end if
end  

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail