|No such thing as a small change|
Random 1-1 mappingby tomazos (Deacon)
|on May 28, 2006 at 17:56 UTC||Need Help??|
tomazos has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to write a simple shuffling function...
...such that shuffle($K1, $K2, $x) == shuffle($K1, $K2, $y) if and only if $x == $y.
shuffle returns a semi-random number.
This could be used to iterate randomly over a read-only list in-place.
Any math geniuses out there care to fill in the calculate $result part? I'm sure it has something to do with moding and hashing and stuff.
(No, this isn't a homework question. :) I actually need it to iterate randomly over a list in a resource-constrained embedded environment where I can't move the memory around - and haven't got spare memory. I knew I shouldn't have slept through my CS lectures.)
Thanks in advance.