Re: Processing numbers in random order
- From: Arthur T. <arthur@xxxxxxxxxxxxxx>
- Date: Tue, 18 Dec 2007 19:15:54 -0500
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
.
- Follow-Ups:
- Re: Processing numbers in random order
- From: Phil
- Re: Processing numbers in random order
- References:
- Processing numbers in random order
- From: Steve Swift
- Re: Processing numbers in random order
- From: Arthur T .
- Re: Processing numbers in random order
- From: Gerard Schildberger
- Re: Processing numbers in random order
- From: Phil
- Re: Processing numbers in random order
- From: Phil
- Re: Processing numbers in random order
- From: Arthur T .
- Re: Processing numbers in random order
- From: Phil
- Processing numbers in random order
- Prev by Date: Re: Processing numbers in random order
- Next by Date: Re: Processing numbers in random order
- Previous by thread: Re: Processing numbers in random order
- Next by thread: Re: Processing numbers in random order
- Index(es):
Relevant Pages
|
Loading