sherkas Posted May 7, 2006 Posted May 7, 2006 Im trying to get logic down and code this. I want a program to generate all possible combinations of letters and numbers for X digits. I cant think of how to start the loops. I was thinking, for all digits, do a loop for all possible letters/numbers but the problem is this. I want say for 10 digits to generate the combinations: a aa aaa aaaa b bbb c ccc abcd abc abcde etc... all combinations even 1 digits. So for UP TO X digits i should say. Can someone help me with some logic on how to start this?
Valuater Posted May 7, 2006 Posted May 7, 2006 this is one way... #include <Array.au3> Dim $R[6] Randomize() _ArrayDisplay( $R, " Array") Func Randomize() $R[1] = Random(1, 47, 1) $R[2] = Random(1, 47, 1) $R[3] = Random(1, 47, 1) $R[4] = Random(1, 47, 1) $R[5] = Random(1, 47, 1) If $R[1] = $R[2] Or $R[1] = $R[3] Or $R[1] = $R[4] Or $R[1] = $R[5] Then Randomize () If $R[2] = $R[3] Or $R[2] = $R[4] Or $R[2] = $R[5] Then Randomize () If $R[3] = $R[4] Or $R[3] = $R[5] Then Randomize () If $R[4] = $R[5] Then Randomize () _ArraySort($R, 0, 1) EndFunc 8)
sherkas Posted May 7, 2006 Author Posted May 7, 2006 That is a random way... but i dont think its quite what im looking for
Paulie Posted May 7, 2006 Posted May 7, 2006 That is a random way...but i dont think its quite what im looking foryou might have gotten more help if you had posted this in support
Valuater Posted May 7, 2006 Posted May 7, 2006 (edited) That is a random way... but i dont think its quite what im looking for yea well this is random also... but it does what you wanted... and couldn't get your "head around" this does 10 digit combinations... none are the same, you can change it to start with 1, then 2 then 3... etc if you want expandcollapse popupDim $combo[1000], $t, $combo_test, $N, $L, $j Run("notepad.exe") WinWaitActive("") Sleep(500) $Letter = StringSplit("A,B,C,D,E,F,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z", ",") $Number = StringSplit("0,1,2,3,4,5,6,7,8,9", ",") While $j < UBound($combo) - 1 Get_combo() For $t = 1 To UBound($combo) - 1 If $combo[$t] = $combo_test Then ExitLoop If $combo[$t] = "" Then $combo[$t] = $combo_test $j = $j + 1 ;MsgBox(64, "Combonation " & $t, $combo[$t] & ' ', 1) Send("Combonation " & $t & " = " & $combo[$t] & @CRLF) Sleep(300) ExitLoop EndIf Next WEnd Func Get_combo() $combo_test = "" While StringLen($combo_test) < 10 $L = $Letter[ (Random(1, $Letter[0], 1)) ] $N = $Number[ (Random(1, $Number[0], 1)) ] $test = Random(1, 2, 1) If $test = 1 Then $combo_test = $combo_test & $L Else $combo_test = $combo_test & $N EndIf WEnd EndFunc ;==>Get_combo tested to over 500.. then i exited................. Thanks Valuater 8) Edited May 7, 2006 by Valuater
sherkas Posted May 7, 2006 Author Posted May 7, 2006 hmm I guess i need to really read it and understand it, because i tested it and saw that it worked, but.... i didn't see how it being random would do it. than ks, will read this and try tounderstand it.
GioVit Posted May 8, 2006 Posted May 8, 2006 Try this Run("notepad.exe") WinWaitActive("") Sleep(500) $Letter = StringSplit("A,B,C,D,E,F,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9", ",") Combi("", 5) Func Combi($Str, $MaxLen) Dim $i if StringLen($Str) = $MaxLen Then Send("Combination = " & $Str & @CRLF) ; Sleep(50) Return EndIf For $i = 1 to $Letter[0] Combi($Str & $Letter[$i], $MaxLen) Next EndFunc Pure recursion
chacoya121 Posted April 14, 2017 Posted April 14, 2017 can you put 2 digits in side and make a combination AAA01 AAA02 skip the letter but put 2 numbers inside the
Moderators JLogan3o13 Posted April 14, 2017 Moderators Posted April 14, 2017 @chacoya121 did you happen to notice this thread is over 11 years old? Please don't resurrect old threads. If you have a question, create a new thread (in the correct section such as General Help and Support not the Examples forum), and explain what you're trying to accomplish. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
TheSaint Posted April 14, 2017 Posted April 14, 2017 @chacoya121 With your new topic in General Help & Support, you could also include a link back to this topic, which might also make it clearer for those trying to help you. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
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