Technology Programming

David Reed"s Entry for the Unique Random Numbers Generator

Question: David Reed's Entry for the Unique Random Numbers Generator

Challenge: a custom Delphi function, Randomizer, takes an open integer array and should fill it with unique random numbers as fast as possible.

The code is submitted for the Unique Random Numbers Delphi Challenge

Answer:

Unique random number generator entry by David Reed (USA):

procedure Randomizer_David_Reed(const maxValue : int64; var values : array of int64) ; var   x,y,xVal,xLen: integer;   a: array of int64; begin   xLen := Length(values) ;   xVal := maxValue div xLen;   SetLength(a,xLen) ;   // Generate a set of unique sorted random numbers..   for x := 0 to xLen - 1 do     a[x] := (xVal * x) + Random(xVal) + 1;   // Randomly assign the random unique values to   // the values array..   for x := xLen - 1 downto 0 do begin     y := Random(x) ;     values[x] := a[y];     a[y] := a[x];   end; end;

Test data:
- array size: 10 000
- number range: 1 - 100 000

David's speed result: 370 microseconds.

Explore the list of all accepted entries for the Fastest Unique Random Number Generator Delphi challenge.
SHARE
RELATED POSTS on "Technology"
WordPress - How to Set up a New Theme to WordPress 3.
WordPress - How to Set up a New Theme to WordPress 3.
Solution of Creative Web Design
Solution of Creative Web Design
The three disciplines of User Experience
The three disciplines of User Experience
Web Design Sheffield Options For Professional Enterprises
Web Design Sheffield Options For Professional Enterprises
Do you have what it takes?
Do you have what it takes?
Segway Cost
Segway Cost
Microsoft Access 2010: What's Coming with Office 2010?
Microsoft Access 2010: What's Coming with Office 2010?
Companies of Web Development in Ireland Provide Designs that Work
Companies of Web Development in Ireland Provide Designs that Work
Penguin Update to Put Red-Flags on Negative SEO
Penguin Update to Put Red-Flags on Negative SEO
Innovative web 2 design templates can make your business famous quickly
Innovative web 2 design templates can make your business famous quickly
Building A Search Engine Friendly Website
Building A Search Engine Friendly Website
Exceptional Advice To Build Up Your Internet Marketing
Exceptional Advice To Build Up Your Internet Marketing
The Benefits of Selecting The Right Hosting Company
The Benefits of Selecting The Right Hosting Company
Is There a Methodology for Making Successful Logos
Is There a Methodology for Making Successful Logos
Benefits of Ruby On Rails Development
Benefits of Ruby On Rails Development
The Power of Colour and Shapes in Your Infant's Life.
The Power of Colour and Shapes in Your Infant's Life.
Advantages of Hiring PSD To HTML Service Providers
Advantages of Hiring PSD To HTML Service Providers
How to Make Responsive Web Design Attractive?
How to Make Responsive Web Design Attractive?
Converting PSD to Responsive HTML
Converting PSD to Responsive HTML
Just a few realy really hints and tips when it comes to website design but look for.
Just a few realy really hints and tips when it comes to website design but look for.

Leave Your Reply

*