aeau2080 Posted May 12, 2013 Share Posted May 12, 2013 (edited) i need to generate a .txt list of all possible combinations of a predefined set of words with no word repeated in the same combination For example, if the words are 1, 2, 3 I'd need the following list: 1 2 3 12 13 21 23 31 32 123 213 231 132 312 321 Edited May 12, 2013 by aeau2080 Link to comment Share on other sites More sharing options...
guinness Posted May 12, 2013 Share Posted May 12, 2013 What's your overall agenda? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
mikell Posted May 12, 2013 Share Posted May 12, 2013 (edited) Try this, recursive way It's brute force so good luck $Form1 = GUICreate("Form1", 150, 310, 200, 100) $List = GUICtrlCreateList("", 20, 20, 110, 250) $label = GUICtrlCreateLabel("", 20, 280, 110, 20) Global $text[7] = ["1", "2", "3", "4", "5", "6", "7"], $n = 0 SplashTextOn ("", "Loading...", 180, 60, -1, -1, 49) _LetsGo("") GUICtrlSetData($label, $n & " solutions") SplashOff() GUISetState() While GUIGetMsg()<>-3 Wend Func _LetsGo($string) For $i = 0 to UBound($text)-1 If not Stringinstr($string, $text[$i]) Then _LetsGo($string & $text[$i] ) GUICtrlSetData($List, $string & $text[$i] & "|") $n += 1 EndIf Next EndFunc Edited May 12, 2013 by mikell Link to comment Share on other sites More sharing options...
aeau2080 Posted May 12, 2013 Author Share Posted May 12, 2013 (edited) what does this do.... it just opens a splash saying loading,,,, i need it to create a txt file with the combinations to use as a dictionary Edited May 12, 2013 by aeau2080 Link to comment Share on other sites More sharing options...
mikell Posted May 12, 2013 Share Posted May 12, 2013 There are 13699 possibles combinations... you have to wait a moment before the list is created This is the engine, it's not so difficult to replace in the script the writing to a list by a writing to a file ^^ Link to comment Share on other sites More sharing options...
aeau2080 Posted May 12, 2013 Author Share Posted May 12, 2013 i am a n00b, so which part to change? Link to comment Share on other sites More sharing options...
mikell Posted May 12, 2013 Share Posted May 12, 2013 (edited) Here it is... faster without a gui Global $text[7] = ["1", "2", "3", "4", "5", "6", "7"], $n = 0 $file = FileOpen(@scriptdir & "\list.txt", 1) _LetsGo("") FileClose($file) Exit Func _LetsGo($string) For $i = 0 to UBound($text)-1 If not Stringinstr($string, $text[$i]) Then FileWrite($file, $string & $text[$i] & @crlf) _LetsGo($string & $text[$i] ) EndIf Next EndFunc Ok it's sorted now Edited May 12, 2013 by mikell aeau2080 1 Link to comment Share on other sites More sharing options...
jchd Posted May 13, 2013 Share Posted May 13, 2013 @aeau2080, What you're after is the list of all permutations of all non-empty subset of a set of 7 elements (the 7 names you used). It's easy to show that the number of such subsets (without respect to order of their elements) is 2N - 1 for an initial set on N elements, so in your case 27-1 = 127. This is the initial subset count: 7 subsets of length 1 21 subsets of length 2 35 subsets of length 3 35 subsets of length 4 21 subsets of length 5 7 subsets of length 6 1 subsets of length 7 Note: the values 1 - 7 - 21 - 35 - 35 - 21 - 7 -1 is the 7th row of the Pascal triangle (giving binomial coefficients). Then you have to enumerate the permutations of these subsets. For each subset of length N there are N! permutations. Hence the actual count of all the list you want to try is: 1 * 7 lists of length 1 = 7 2 * 21 lists of length 2 = 42 3*2 * 35 lists of length 3 = 210 4*3*2 * 35 lists of length 4 = 840 5*4*3*2 * 21 lists of length 5 = 2520 6*5*4*3*2 * 7 lists of length 6 = 5040 7*6*5*4*3*2 * 1 lists of length 7 = 5040 As Mikell said, this is a big total of 13699 lists each comprising 1 to 7 names, so it is little surprise that it takes some time to build. You can also combine the actions of _ArrayCombinations() then _ArrayPermute() on every result (after removing the 0-th element). The number of lists explodes rapidly. This is that integer sequence. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 13, 2013 Moderators Share Posted May 13, 2013 (edited) We don't need to provide brute force cracking methods for anyone. Please do not start another thread on such a topic. Edit: Permutations are one thing when you can only speculate the use, here there was no denying the usage which is why I warned and closed this thread. Edited May 13, 2013 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts