RazerM Posted April 7, 2006 Posted April 7, 2006 Is there any way to get every possible so for example 123 returns 123 132 231 213 312 321 I didnt know what to search for, sorry if its been posted before My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Tafkadasom2k5 Posted April 7, 2006 Posted April 7, 2006 (edited) Hi there!Put these variables in an array and then see the helpfile in "_ArraySort":#include <Array.au3> _ArraySort ( ByRef $a_Array, [$i_Descending[, $i_Base=0[, $i_Ubound=0[, $i_Dim=1[, $i_SortIndex=0]]]]] )Hope that'l help,Gr33tzTafkadasom2k5EDIT: Oh, I've missunderstood youre Question.... I'll try again later, OK? xD Edited April 7, 2006 by Tafkadasom2k5
RazerM Posted April 7, 2006 Author Posted April 7, 2006 i don't see how that'll help. I have a variable $var=123456789 and i want every possible order to be put into an array $var[0]=123456789 $var[1]=123456798 $var[2]=123456987 or something like that. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Moderators SmOke_N Posted April 7, 2006 Moderators Posted April 7, 2006 /dev/null wrote this:expandcollapse popupfunc rotate($sString, $nRotateLevel) local $aStringArray = StringSplit($sString,"") local $nStartRotate = $aStringArray[0] - $nRotateLevel + 1 local $n, $tempchar, $tempstr = "", $retval = "" for $n = 1 to $nStartRotate - 1 $tempstr= $tempstr & $aStringArray[$n] next $tempchar = $aStringArray[$nStartRotate] for $n = $nStartRotate+1 to $aStringArray[0] $retval = $retval & $aStringArray[$n] next $retval = $tempstr & $retval & $tempchar return $retval endfunc func permute_internal($sString, $nRotateLevel, byref $permutations) local $n, $str dim $arr[$nRotateLevel] if $nRotateLevel = 2 then $permutations = $permutations & ":" & rotate($sString,$nRotateLevel) return endif $str = $sString for $n = 0 to $nRotateLevel -1 $str = rotate($str,$nRotateLevel) $arr[$n] = $str ;--- special check, to stop a level beeing printed twice --- if not (($n = 0) AND (StringLen($sString) > $nRotateLevel)) then $permutations = $permutations & ":" & $arr[$n] endif permute_internal($arr[$n],$nRotateLevel-1,$permutations) next endfunc func permute($sString) global $permutations = "" permute_internal($sString,StringLen($sString),$permutations) $permutations = StringTrimLeft($permutations,1) return StringSplit($permutations,":") endfunc ;----------------------------------------------------------------------------- ;-- MAIN ;----------------------------------------------------------------------------- $permutarray = permute("1234") $msg = "" for $n = 1 to $permutarray[0] $msg = $msg & $permutarray[$n] & @CRLf next msgbox(0,"", $msg)And it works... 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.
RazerM Posted April 7, 2006 Author Posted April 7, 2006 thanks Smoke_N!! My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Bokkie Posted April 7, 2006 Posted April 7, 2006 thanks Smoke_N!!This link is a better solution as it describes factoradic permutations. Of course you'll have to prove the math for yourself but it's totally non-recursive and therefore rips the recursive algorithms to shreds, especially if you are want very large permutation lists.
Moderators SmOke_N Posted April 7, 2006 Moderators Posted April 7, 2006 This link is a better solution as it describes factoradic permutations. Of course you'll have to prove the math for yourself but it's totally non-recursive and therefore rips the recursive algorithms to shreds, especially if you are want very large permutation lists.Do you have that broken down so it can be used in AutoIt? 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.
Bokkie Posted April 7, 2006 Posted April 7, 2006 Do you have that broken down so it can be used in AutoIt?SmOke_N, I have the .Net code on my machine and it compiles cleanly and executes successfully. If you think it has general appeal to a wider audience I'd be happy to write an AutoIT function to do the same.Let me know your thoughts on the matter.
Moderators SmOke_N Posted April 8, 2006 Moderators Posted April 8, 2006 SmOke_N, I have the .Net code on my machine and it compiles cleanly and executes successfully. If you think it has general appeal to a wider audience I'd be happy to write an AutoIT function to do the same.Let me know your thoughts on the matter.I think a more efficient method for a permutation function would be wonderful personally, I've never sat down personally to try and perfect it, after 8 or 9 digits, it does get a bit lengthy.I timed 7 through 9 and this is what it showed: (3.7 ghz / 2 gig ddr)2.01868863094332 seconds for 7 numbers (5,040 combinations)1 minute, 54.901296673181 seconds for 8 numbers (40,320 combinations)And Wow...6 hours, 26 minutes, and 6.4094553917 seconds for 9 numbers (362,880 combinations) 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.
Bokkie Posted April 8, 2006 Posted April 8, 2006 I think a more efficient method for a permutation function would be wonderful personally, I've never sat down personally to try and perfect it, after 8 or 9 digits, it does get a bit lengthy.I timed 7 through 9 and this is what it showed: (3.7 ghz / 2 gig ddr)2.01868863094332 seconds for 7 numbers (5,040 combinations)1 minute, 54.901296673181 seconds for 8 numbers (40,320 combinations)And Wow...6 hours, 26 minutes, and 6.4094553917 seconds for 9 numbers (362,880 combinations)With times like those I definitely see a case for adopting the factoradic math solution. I have a lot on my plate at work and home but I'll certainly get round to doing it!
Bokkie Posted April 17, 2006 Posted April 17, 2006 (edited) I timed 7 through 9 and this is what it showed: (3.7 ghz / 2 gig ddr)And Wow...6 hours, 26 minutes, and 6.4094553917 seconds for 9 numbers (362,880 combinations)SmOke_N, I think I can improve on that. Using the factoradic math solution I generated all 362880 permutations for order-9 in approximately 15 minutes 50 seconds! I'm about 85% completed with the coding so I'll touch base with you later about publishing the library of functions I've written.Edit: I calculated the 45,436,342,987,433th permutation of order-123. It took 0.3149s. Edited April 18, 2006 by Peter Hamilton-Scott
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now