Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Generating random 6 digit numbers

by jotti (Scribe)
on Aug 28, 2002 at 08:03 UTC ( [id://193383]=note: print w/replies, xml ) Need Help??


in reply to Generating random 6 digit numbers

Divide the problem into two:

  • Create a true random generator or get one. There are better and worse pseudo-random generators. Most algorithmic ones are pseudo. One attempt to a true one would be to place the computer's microphone near the fan or any other noisy equipment and read the least significant bit from the mic port and put together a n-bit number.
  • Create the 6 digit numbers.
    • If you want all 6 digits to be unique, put all digits from 0 to 9 in an array, shuffle it using your random generator and pick the 6 first digits. If first digit can't be zero and the first item in the shuffled array is zero, just pick the 6 next digits.
    • If you want each new 6-digit-number to be unique, create an array with the numbers 100,000 to 999,999 and shuffle it. Then pick them in order.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://193383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found