HeniutX Posted July 13, 2011 Share Posted July 13, 2011 I have 07366024802gntlwcqybjf , And I want to do this for example: 0q3j60l4bn2g0t2wc7y86f So, I mean the mixing of characters. I apologize for mistakes. I come from a Polish Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 13, 2011 Share Posted July 13, 2011 Well I wrote this kinda quick. It works, but doesn't use every character in the original string, and sometimes repeats a character already used.. $sString = "07366024802gntlwcqybjf" $aString = StringSplit($sString, "") ConsoleWrite($sString & @LF) For $c = 1 to $aString[0] ConsoleWrite($aString[Random(1, $aString[0], 1)]) Next ConsoleWrite(@LF) - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
smartee Posted July 13, 2011 Share Posted July 13, 2011 (edited) Here is another way, same concept though #include <Array.au3> ;_StringShuffle by smartee Func _StringShuffle($sString, $iRepetitions=-1) Local $iA, $iB, $cTmp Local $aCharArray = StringSplit($sString, "", 1) If $iRepetitions=-1 Then $iRepetitions=$aCharArray[0] For $i = 1 To $iRepetitions $iA = Random(1, $aCharArray[0], 1) $iB = Random(1, $aCharArray[0], 1) $cTmp = $aCharArray[$iA] $aCharArray[$iA] = $aCharArray[$iB] $aCharArray[$iB] = $cTmp Next Return _ArrayToString($aCharArray,"",1) EndFunc ;==>_StringShuffle MsgBox(64,"_StringShuffle",_StringShuffle("Hello World")) EDIT: code typo with repetition 4 times Edited July 13, 2011 by smartee Link to comment Share on other sites More sharing options...
Spiff59 Posted July 14, 2011 Share Posted July 14, 2011 (edited) And another way to skin the cat... MsgBox(1, "", scramble("1234567890")) ;---------------------------------------------------------------- Func scramble($str) Local $work = StringSplit($str, ""), $out = "" For $max = $work[0] to 2 Step -1 $rnd = Random(1, $max, 1) $out &= $work[$rnd] $work[$rnd] = $work[$max] Next Return $out & $work[1] EndFunc Edited July 14, 2011 by Spiff59 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