Note that there are some explanatory texts on larger screens.

plurals
  1. POLooking for an algorithm to spit out a sequence of numbers in a (pseudo) random order
    primarykey
    data
    text
    <p>Suppose I have a sequence of numbers: {n, n+1, n+2, ... n + m}</p> <p>Without storing the numbers ahead of time I want to create a function f(), which given the sequence {1,2,3,...m} will spit out the original set in a random (or at least pseudo random) order.</p> <p>For example assume my sequence is {10, 11, 12, 13, 14, 15, 16, 17}</p> <pre> f(1) could yield 14 f(2) could yield 17 f(3) could yield 13 f(4) could yield 10 f(5) could yield 16 f(6) could yield 15 f(7) could yield 11 f(8) could yield 12 </pre> <p>At one point in the past a co-worker showed me a mathematical algorithm that was able to do this, but I have since forgotten almost everything about it other than it existed. I remember that you had to have the sequence in advance, and generate some constants from the sequence which were used in the function. And for those wondering, I have sadly lost contact with that co-worker.</p> <p>This <a href="https://stackoverflow.com/questions/693880/create-random-number-sequence-with-no-repeats">question's</a> answers looks close to what I want, but I am not sure if the answers allow me to constrain the output to a specific sequence ahead of time.</p> <hr> <p><strong>Edit:</strong></p> <p>To clarify a little more I don't want to store the original sequence, or the shuffled sequence. I want to generate a function f() from the original sequence.</p> <p>What is frustrating is that I have seen this, I just cannot remember enough about it to find it again with google.</p> <p>The Fisher-Yates algorithm is great for permuting or shuffling a deck, but it is not what I am looking for.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload