On 16/05/17 23:46, Richard Kuebbing wrote:
Fantastic.  This looks to be the level of brilliance I was looking
for - simplicity plus 100% solution.

To generate a random permutation of the numbers from 1 to 99,999
the usual method is the Fisher-Yates shuffle, dating from 1938:

https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

This takes O(n) time, as opposed to O(n log n) for Peter's
"generate and sort" method. With only 99,999 numbers the extra CPU time
may not be significant, depending on how often you need to generate
a sequence.

There are various statistical tests for randomness, if you don't
entirely trust your random number generator:

https://en.wikipedia.org/wiki/Randomness_tests

If the random number generator is needed for cryptography,
then more tests are needed: ideally a "truly" random number
generator (based on some physical random activity) which seeds
the pseudo random number generator. Many years ago I built
such a device using the noise generated by a reverse-biased diode.

Here is an example of such a circuit:

http://holdenc.altervista.org/avalanche/

--
                        Martin

Dr Martin Ward STRL Principal Lecturer & Reader in Software Engineering
[email protected]  http://www.cse.dmu.ac.uk/~mward/  Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/
Mirrors:  http://www.gkc.org.uk  and  http://www.gkc.org.uk/gkc

Reply via email to