7121 Posted April 19, 2009 Share Posted April 19, 2009 basically i have this $Ran = Random(1, 9 ) Which btw, does anyone know how to make random like a huge number, without FLOAT??? o_0 okay, after that, $Ran = $Ran*123456789 $Ran = Int ($Ran) easiest way i know to make a huge RANDOM number as an integer =/ Now the problem is i don't want duplicates . example: 11, 2222, 33333333, 444, basically i only want 1712938125, each number is different on every next digit. I think it's really easy but somehow i'm not figuring it out and i go with manual of StringReplace... like LOTS of them, about 20 of them, hoping the duplicate won't show up. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 19, 2009 Moderators Share Posted April 19, 2009 7121,Random will deal with numbers up to 2^31 (that is up to 2,147,483,647) - I think that counts as 'huge'. Setting the 'Flag' parameter will return integers - so that is the first question dealt with!Now to the 'duplicate' problem - as you do not want successive integers to be the same, we are already outside any real defintion of "random", so why not just amend the numbers so they no longer match? Although I feel we should make at least a token effort by increasing or decreasing them at random! :-):; Get large integer $sInt = String(Random(1000000, 10000000, 1)) ; Split into elements $aInt = StringSplit($sInt, "") ; Increase/decrease elements randomly if they match preceding element For $i = 1 To $aInt[0] - 1 If $aInt[$i + 1] = $aInt[$i] Then $iUpDown = Random(0, 1) If $iUpDown > .5 Then $aInt[$i + 1] += 1 If $aInt[$i + 1] = 10 Then $aInt[$i + 1] = 0 Else $aInt[$i + 1] -= 1 If $aInt[$i + 1] = -1 Then $aInt[$i + 1] = 9 EndIf EndIf Next ; Recreate number $sInt = "" For $i = 1 To $aInt[0] $sInt &= $aInt[$i] Next $iInt = Int(Number($sInt)) ; Display it ConsoleWrite($iInt & @CRLF)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TheSaint Posted April 19, 2009 Share Posted April 19, 2009 basically i have thisNow the problem is i don't want duplicates .example:11, 2222, 33333333, 444, basically i only want 1712938125, each number is different on every next digit. I think it's really easy but somehow i'm not figuring it out and i go with manual of StringReplace... like LOTS of them, about 20 of them, hoping the duplicate won't show up.I'd go with StringMid and count your way through the number, and keep incrementing so that next number doesn't match last, so that11, 2222, 33333333, 444, would become12, 3232, 34343434, 545,if you just incremented by 1 each time.If you vary the increment each time, then you would get a less uniform number. 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) Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2009 Share Posted April 19, 2009 Now the problem is i don't want duplicates .example:11, 2222, 33333333, 444, basically i only want 1712938125, each number is different on every next digit. I think it's really easy but somehow i'm not figuring it out and i go with manual of StringReplace... like LOTS of them, about 20 of them, hoping the duplicate won't show up.There are plenty of high quality proven random number generators floating around, just google. BTW, discarding 33333 is definitely not a good idea. 33333 is as random as 57404583 can be. It "just" happen to have a decimal expression that makes it easy to spot. Express your numbers in hex and you'll find a completely different set of "not looking random" numbers. Then try octal or binary or ... Even duplicates in 2^32 are "normal" (I won't go into a mathematical discussion about what that means).Duplicates might be unsuited to your precise application, but they are nothing else than "normal". Not finding any would be a _big_ security breach! Think about it: roll a dice and apply your paradigm: if you got 3 then you must get something else! Roll the dice 5 times and --if dups are banned-- I for one that can predict which shall be the next number. This is clearly getting more and more predictable (the contrary to random) as the number of values already appeared increase and tend towards the number of possibilities. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 20, 2009 Share Posted April 20, 2009 ConsoleWrite(_randomNr(10) & @CRLF) Func _randomNr($length = 1) Local $nr = Random(0, 9, 1), $tmp = '' While StringLen($nr) < $length $tmp = Random(0, 9, 1) If $tmp <> StringRight($nr, 1) Then $nr &= $tmp WEnd Return $nr EndFunc ;==>_randomNr Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
7121 Posted April 24, 2009 Author Share Posted April 24, 2009 thank you very much guys... even though i'm still a little confused but i'll figure it out 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