Jump to content

Search the Community

Showing results for tags 'permutation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. This snippet works perfectly for nested spintax: However, I can't figure out how I can write a function that will output all the permutations of nested spintax. For example: for a string "John went to the {{grocery |}store|library}" I would get: John went to the library John went to the store John went to the grocery store ... I can't figure this out - - I can kinda figure it out if there isn't any nesting (regex out all the text between brackets)...but nesting makes it pretty complicated for me to wrap my head around :)
  2. Hi guys!, i have a problem to convert Python code to AutoIt code, in fact i had not coded with Python yet!, this code is about permutation a string's case, i will be happy with your comments :)❤; Python code: # Python code to print all permutations # with respect to cases # Function to generate permutations def permute(inp): n = len(inp) # Number of permutations is 2^n mx = 1 << n # Converting string to lower case inp = inp.lower() # Using all subsequences and permuting them for i in range(mx): # If j-th bit is set, we convert it to upper case combination = [k for k in inp] for j in range(n): if (((i >> j) & 1) == 1): combination[j] = inp[j].upper() temp = "" # Printing current combination for i in combination: temp += i print(temp), # Driver code permute("Hello") # This code is contributed by Sachin Bisht My code in AutoIt: ; https://www.geeksforgeeks.org/permute-string-changing-case/ _PermuteCase("ABC") Func _PermuteCase($sText) If StringRegExp($sText, "^[A-Za-z]{1,}$") Then Local $iLength = StringLen($sText) ; Get length of the text. Local $iMaxPerm = 2 ^ $iLength ; Number of permutations is 2^n Local $sLow_Text = StringLower($sText) ; Converting string to lower case Local $asChrs = StringToASCIIArray($sLow_Text) ; Split the text into array of chars. For $i = 1 To $iMaxPerm Step 1 For $j = 0 To $asChrs[0] ;................................................... Next Next Else Return SetError(-1, 0, "Error: Input is incorrect!") EndIf EndFunc ;==>_PermuteCase ====================== SOLUTION by @TheXman ======================
  3. Hello, got bored and wrote a script to see how efficiently I could enumerate all possible combinations of a set of data(I was watching Elysium and saw the 4-digit lock cracking program spider user near the end, and got inspired). [Note: Though the idea was inspired by use of such a program to crack a lock, I please ask you don't use my code to try to crack any locks/passwords, fun/education only please!] Below is an example that fetches all the possible combinations of the digits 0-9. It takes about 60 seconds, which is pretty good consider it has to do 157,464 calculations. I believe this is the fastest method of permuting data. It's also extremely efficient on ram, as it only remembers the viable results, not all results of all calculations. I wish there was some way to support more or less length, but as far as I can tell there is no way to do this(I don't think you can have a dynamic amount of nested loops), if you have a way, I welcome you to show me. [if you want it to use more or less length, just add/remove for loops and values as necessary] #include <Array.au3> _ArrayDisplay(_permute_4('0123456789')) func _permute_4($string) Local $permuted = '', $sourcearray, $aArray, $aNewArray, $opcount = 0 $sourcearray = StringSplit($string, "") $timer = TimerInit() for $i = 1 to $sourcearray[0] for $i2 = 1 to $sourcearray[0] for $i3=1 to $sourcearray[0] for $i4=1 to $sourcearray[0] if $i=$i2 and $i2 = $i3 and $i3 = $i4 Then $permuted&="|"&$sourcearray[$i]&$sourcearray[$i2]&$sourcearray[$i3]&$sourcearray[$i4] $opcount +=1 Else if StringRegExp($permuted, "(.*?)("&$sourcearray[$i]&$sourcearray[$i2]&$sourcearray[$i3]&$sourcearray[$i4]&")(.*?)") Then ConsoleWrite("Data already permuted"&@CRLF) Else Local $aArray[4] = [$sourcearray[$i], $sourcearray[$i2], $sourcearray[$i3], $sourcearray[$i4]] Local $aNewArray = _ArrayPermute($aArray) ;Using Default Parameters $opcount +=30 for $ix=1 to 24 if Not StringRegExp($permuted, "(.*?)("&$aNewArray[$ix]&")(.*?)") and $aNewArray[$ix] <> "" Then $permuted &= '|'&$aNewArray[$ix] ConsoleWrite(StringLen($permuted)/5&@CRLF) EndIf $opcount +=1 Next EndIf EndIf Next Next Next Next $time = TimerDiff($timer) ConsoleWrite("Took "&$time&" MS for "&$opcount&' operations.'&@CRLF) $permuted = StringSplit(StringTrimLeft($permuted,1), "|") return $permuted EndFunc
×
×
  • Create New...