billthecreator Posted June 9, 2009 Share Posted June 9, 2009 I believe this had been done, I just added errors and made the script clear. the example is in the script, on top, just unblock the comment... you'll see it. GenerateRandomNoRepeat.au3 tazlikesrobots 1 [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
Ashalshaikh Posted June 9, 2009 Share Posted June 9, 2009 That's great ..... I will save It Thank you Link to comment Share on other sites More sharing options...
WideBoyDixon Posted June 9, 2009 Share Posted June 9, 2009 Some observations that I hope you won't mind: [1] There needs to be a sanity check that you're not asking for something you can't have. For example: _GenerateRandomNoRepeat(12, 4, 10) Will presumably never return. [2] It would be nice to be able to pass a seed through to the function for initialization of the Random function. This would allow the same array to be generated twice using the same seed. Always useful to be able to generate the same "random" sequence twice [3] I'm not convinced the algorithm is as efficient as it could be when, for example, I call it with: _GenerateRandomNoRepeat(52, 1, 52) Getting the last number could take a very long time. In those cases, it might be better to create an array containing all the possible numbers 1 to 52, shuffling the array and then returning the first X numbers as appropriate. Obviously this is not an efficient algorithm for: _GenerateRandomNoRepeat(2, 1, 10000) So perhaps there could be some logic in order to choose the best way forward. Regards, WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
tazlikesrobots Posted December 8, 2015 Share Posted December 8, 2015 great UDF. You saved me a lot of time trying to figure out on how to do this! 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