Question
Array.shuffle() & Non-repeat Arrays
First, let me say that I love Rothrock's Array.shuffle() and
I think it an awesome method, give up the props. But I've heard it
said several times that by using the shuffle, it will produce
non-repeating choices from the array.
I could be mis-understanding (probably) or not using it correctly (likely), but I've never been able to understand how 'shuffling' the contents of the array would eliminate any of the possible choices, regardless of the index being chosen at random or statically. although the method does a fabulous, perfectly conceived, stupendous, superbly executed (that was butter for Rothrock 🙂 job of shuffling it, I don't see how it's still not possible for items to occationally repeat, through natural random chaos. Granted the more elements in the array, the less likely this occurs, but I believe it will occur.
I did a little experiment to see what happens, and it seems to validate this, but I'm probably doing something wrong anyway. So I though I'd open a disscussion, because I'd like to know more, and get some of the thoughts on this from everyone, maybe work out a solution, or tell me what the heck I'm doing wrong.
Once again though, no shot a Rothrock here, this method truely 'rocks'. Just quest for knowledge.
Here's the code I used, very simple, try it out and pick it apart:
I could be mis-understanding (probably) or not using it correctly (likely), but I've never been able to understand how 'shuffling' the contents of the array would eliminate any of the possible choices, regardless of the index being chosen at random or statically. although the method does a fabulous, perfectly conceived, stupendous, superbly executed (that was butter for Rothrock 🙂 job of shuffling it, I don't see how it's still not possible for items to occationally repeat, through natural random chaos. Granted the more elements in the array, the less likely this occurs, but I believe it will occur.
I did a little experiment to see what happens, and it seems to validate this, but I'm probably doing something wrong anyway. So I though I'd open a disscussion, because I'd like to know more, and get some of the thoughts on this from everyone, maybe work out a solution, or tell me what the heck I'm doing wrong.
Once again though, no shot a Rothrock here, this method truely 'rocks'. Just quest for knowledge.
Here's the code I used, very simple, try it out and pick it apart: