Create Random Number Sequence with No Repeats

You may be interested in a linear feedback shift register.
We used to build these out of hardware, but I’ve also done them in software. It uses a shift register with some of the bits xor’ed and fed back to the input, and if you pick just the right “taps” you can get a sequence that’s as long as the register size. That is, a 16-bit lfsr can produce a sequence 65535 long with no repeats. It’s statistically random but of course eminently repeatable. Also, if it’s done wrong, you can get some embarrassingly short sequences. If you look up the lfsr, you will find examples of how to construct them properly (which is to say, “maximal length”).

Leave a Comment