boringduck Posted December 19, 2003 Share Posted December 19, 2003 heeeeelp.... Hello, Is this possible.... i have a string 'abcdefg' and i want to make a script to make all possible words from this string.... for example: a, ab, ac,.... agaaaa etc..... thanks for the help.... :iamstupid: Link to comment Share on other sites More sharing options...
scriptkitty Posted December 19, 2003 Share Posted December 19, 2003 (edited) To be honest, that would be an endless loop as the one you described, now if you only allowed all the letters to be used once, or only as many as the total you have it may work without going into an endless loop. Do you want it to do all possible answers with only the letters used max once? IE: "abc" a b c ab ac bc ba ca cb abc acb bac bca cab cba ? Boggle or something? I forgot exactly how this is done, but I would start by putting them all into an array, ex: dim $c[10] $x="abc" $y=$x $count=0 while StringLen ($y)>0 $c[$count]=StringLeft($y, 1 ) $y=StringTrimLeft( $y,1 ) $count=$count+1 Wend msgbox(1,$x, $c[0]&@lf&$c[1]&@lf&$c[2]) sloppy, but easy to understand I think. This one changes the array depending on how many entered. I thought a bit about it, but too early in the morning for me yet. $x=InputBox("Question", "What set of letters?", "", "", -1, -1, 0, 0) dim $c[StringLen($x)] ;$x="abc" $y=$x $count=0 while StringLen ($y)>0 $c[$count]=StringLeft($y, 1 ) $y=StringTrimLeft( $y,1 ) $count=$count+1 Wend $out="" for $c1= 0 to $count-1 $out=$out & $c[$c1] & @lf next msgbox(1,$x, $out) Edited December 19, 2003 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
boringduck Posted December 22, 2003 Author Share Posted December 22, 2003 Already thanks for the help but It should be possible that for exemple the a is used 2 or more times in the same word.... Link to comment Share on other sites More sharing options...
Developers Jos Posted December 22, 2003 Developers Share Posted December 22, 2003 Sounds like password hacking to me What max length word should it be or is it unlimited ?? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
boringduck Posted December 22, 2003 Author Share Posted December 22, 2003 the length of the word should be variable... Link to comment Share on other sites More sharing options...
Developers Jos Posted December 23, 2003 Developers Share Posted December 23, 2003 this script will generate a file test.txt that contains all possibilities of the characters put in the $STR var. $Mlen sets the lenght limit Jos $str="A,B,C,D,E,F,G" $chars=StringSplit($str,",") $file = FileOpen("test.txt", 2) $MLen = 4 ; max length of the output $tout="" Dim $Ntout[$MLen+1] for $x = 1 to $MLen $Ntout[$x] = chr(0) next $Ntout[1] = chr(0) ; endless loop While 1=1 For $x = 1 to $chars[0] FileWriteLine($file, $tout & $chars[$x] & @lf) next $tout="" $n2 = 0 for $x = 1 to $mlen if $x = 1 then $n = ASC($Ntout[$x]) + 1 else $n = ASC($Ntout[$x]) + $n2 endif $n2 = 0 IF $n > $chars[0] then $n = 1 $n2 = 1 endif $Ntout[$x]=chr($n) if $n > 0 then $tout=$chars[$n] & $tout endif next if stringlen($tout) = $mlen then exitloop endif wend FileClose($file) Exit SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
scriptkitty Posted December 23, 2003 Share Posted December 23, 2003 nice JdeB, I stopped thinking about it when I thought of the uses. Nice way to do it, AutoIt is very versitile. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 23, 2003 Developers Share Posted December 23, 2003 (edited) I know what it could be used for (I mentioned that in my earlier post... but just wanted to see if it was possible... and thought ... 'What the HACK' that shouldn't be my problem.... Jos Edited December 23, 2003 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
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