edit 2:
what kind of statistical test do I need to get an idea of the randomness of the order of a list? The list contains all base-4 numbers from 0000 to 3333 exactly once.
edit 1:
I've added this as an edit, because it's too long for the comment I think.
I want a function y=f(x) that I can call with a counter x (x = 0, 1, 2, 3, ...). The return value y of the function must be the same for the same x. This is the case if the function returns y=x or if it returns y=x+1 or if it returns y=x+2 and so on. But it is also the case if y = arr[x] in which x is the index of an array that contains no duplicates. For example the array contains random values that are filtered for duplicates. Filtering however takes O(n^2) time. On the other hand returning y=x+1 is very fast, but then y is certain to look like x for all x. So my question is, can a function be made in which y does not look like x, but that takes less than O(n^2) time and does not use n storage space? From what I've created I'm tempting to believe that it can. But I would rather know who has done this before, because I'm not able to prove my concept except by exhaustive testing and therefore I don't want to use it in my code.
original:
My question is "is there a function that can do the same as the first tree lines in the code below, without creating an array of 1000 items?".
I don't want to create an array, because the array must be stored and searched each time I change the upper bound.
var arr = [];
for (var i = 0; i < 1000; i = i + 1) { arr.push(i); }
arr.scramble();
for (var i = 0; i < 1000; i = i + 1) { console.log(arr[i]); }
(the above is in base 10, what follows is in base 4)
I came up with an answer that seemed to work somewhat (enumerating in pseudo random order), but not completely. However, today it seems that it does work, but that I did not test it properly.
I created a new piece of code as a jsfiddle. Press the button for a random matrix.
I use a 4x4 matrix, each row can be in any of 24 states. The total number of matrices is therefore 24^4. The initial state of the matrix determines the sequence in which the 256 possible values of a base-4 number are listed.
I tested all 24^4 matrices and after sorting the sequence I got back my original counter, meaning that each item in the sequence is generated exactly once.
Is there a name for this thing? I would like to know if it has been proven to be correct, so I can use it in my code.
I realise that I can only create 24^4 sequences, while the number of possible sequences is 255*254*253*252*...