So I am looking for a program which generates a random pair of values from a given set of keys. The key idea here is to find the highest degree of divergence and minimal repeatability.
Input: Array of keys, systemtime() //as most of the randomizing functions use system time as a parameter
Output: The two keys that have to be returned to the calling function
generatepair(arrayofkeys[], systemtime())
The key requirement is minimal repeatability. Best case scenario would be wherein a pair generated once should not be generated again, unless such a combination is not possible.
Also, there is a global datastore consists of all previously generated pairs, and forbidden pair which cannot be ever generated. But data independence would be highly appreciated.
Additionally, I’ll be coding in PHP if that information might be useful or constraining.
Well firstly, to achieve “best case” repeatability you could simply remove the pair of numbers form the arrayofkeys to avoid them repeating again.
And if you do not want that to happen, you’re not really generating your numbers purely randomly.
To generate your numbers only within a specific range use rand(x,y) where x and y are your limits. You can get those from your arrayofkeys by doing min(arrayofkeys) and max(arrayofkeys).