Re: Processing numbers in random order



In Message-ID:<47685e04$0$5200$afc38c87@xxxxxxxxxxxxxxxxxxxx>,
"Phil" <obrienpw@xxxxxxxxxxxxxxx> wrote:

Maybe #2 was not thought through... but why is #1 incorrect?

Is it not possible to be at index 10 and request a random number from 1-10
and end up swapping 10 with 10?

Yes it should be. However, your change limited it to
swapping with a random number (actually a random location) from
1-9, not 1-10.

Or, are you suggesting that swapping 10 with 10 should never
happen? In that case, as I said, you'll *never* have location 10
have value 10. So, if you had to guess what number was in
location 10, you'd have an 11+% chance of being right instead of
only a 10% chance. Similarly, a game of War between an unshuffled
deck and one shuffled with your #1 would never have a War during
the first run-through.

You could check to see if you're swapping a location with
itself and do nothing. I suspect that it wouldn't speed things up
because you'd do the check many more times than you'd prevent a
"do nothing" swap.

--
Arthur T. - ar23hur "at" intergate "dot" com
Looking for a z/OS (IBM mainframe) systems programmer position
.



Relevant Pages

  • Re: Ive got a brand new processor ...
    ... You should try to find the manual for the board you have as there's a good chance you'll need to do a jumper swap required when swapping out the cpu. ... Your only internet source for spiral staircase plans. ... Experimental Aircraft Association #140897 ...
    (microsoft.public.windowsxp.hardware)
  • Re: its official--McMurray to the #97 (#28?), Busch to the #2, ??? to the #42 in 06
    ... >What intrigues me is that with the reports that Roush will be swapping out ... does that imply that there's a chance that Penske will ...
    (rec.autos.sport.nascar.moderated)
  • I,Robot for Quantum.. Fair Trade?
    ... I had a chance to play Quantum for the first time tonight and I loved ... I am even thinking about swapping out my I,Robot to get one. ...
    (rec.games.video.arcade.collecting)

Loading