![]() Topic awaiting preservation: Challenge your JavaScript skills (Page 1 of 1) |
|
---|---|
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() This is an attempt to spark some conversation or creativity. |
Bipolar (III) Inmate From: |
![]() Am out of energy for the implementation, but I suspect the first trick is actually determining... what is "order" in that array. |
Paranoid (IV) Inmate From: France |
![]() liorean and I proposed some implementations in |
Maniac (V) Mad Scientist From: :morF |
![]() Well, randomising the elements, in its most simple form, would involve a random number generator limited ot the number of elements in your array, and a secondary storage array. The random number generator detemines which index will be read out, then subsequently determines which index its data will go into in the new array. Keep repeating until the counter tells you you've got all of your elements out, and, voila, done. You'd put used indexes into a tokenised list or something, and have a check within your loop to make sure you're not repeating values. |
Bipolar (III) Inmate From: |
![]() Ok, let me see if... well, this, at first, sounded like a challenge: quote:
|
Paranoid (IV) Inmate From: France |
![]() I don't claim the implementation I posted before are good. Btw you can see in that same thread that sometime I trigger a hammer to smash little flies |
Bipolar (III) Inmate From: |
![]() poi, while we're at it, and while I am performing my monthly comp maintenance, would you mind spending some time on Q? |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() |
Paranoid (IV) Inmate From: France |
![]() |
Maniac (V) Mad Scientist From: :morF |
![]() I certainly shall implement it, just as soon as I learn to write Javascript. I could do it for you in PHP, C and possibly Visual Basic... but, lets have a burl and see what we get... |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
![]() Hm.. I may be cheating using a built in array function but here we go: |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() That's an interesting approach, bit. I wonder if it provides an equal chance of all random configurations? |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
![]() heh after looking at poi's post I'm reinventing the wheel (my other solution was liorien's) |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() I guess it didn't really work to ask a question that had already been answered on this forum =) |
Paranoid (IV) Inmate From: France |
![]() For the record, I understood : "If you find this problem simple, wait until others have had a try before posting your answer." as : "Don't let the apparent simplicity fool you. It can be much more complex than it seems ... and Slime uncovered some nifty subtleties in the other thread." |