Jump to content
Sign in to follow this  
aeau2080

How to list all possible combinations for a predefined set of words?

Recommended Posts

aeau2080

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 by aeau2080

Share this post


Link to post
Share on other sites
guinness

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
mikell

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 by mikell

Share this post


Link to post
Share on other sites
aeau2080

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 by aeau2080

Share this post


Link to post
Share on other sites
mikell

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 ^^

Share this post


Link to post
Share on other sites
aeau2080

i am a n00b, so which part to change?

Share this post


Link to post
Share on other sites
mikell

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 by mikell
  • Like 1

Share this post


Link to post
Share on other sites
jchd

@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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites
SmOke_N

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 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.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×