10001110100110101

Sun Mon Tue Wed Thu Fri Sat
6 7 8* 9 10 11 12
13 14* 15 16* 17 18 19
20 [21]* 22 23 24 25 26
27 28 29 30 31* 1 2
3 4* 5 6 7 8 9

[1:12 PM EDT - Mental Exercise: Random card shuffler.]

GY told me about this interesting puzzle that took me a long time to figure out some sort of incomplete solution to.

Basically, here is the scenario:

Someone wrote a program to shuffle a deck of cards by taking the first card, and randomly inserting that card back into the deck. This also includes itself! It would then go to the next card, and then randomly insert that card into the deck. This will continue down to the end of the deck.

Will this algorithm properly randomize the deck? Please explain why or why not.

Does anyone have a quick answer?

Whoops! I explained it incorrectly! It is not a simple insert, but a swap!

Someone wrote a program to shuffle a deck of cards by taking the first card, and randomly SWAPPING that card with any card in the deck. This also includes itself! It would then go to the next card which will then be randomly swapped with any card in the deck. This will continue down to the end of the deck.

Will this algorithm properly randomize the deck? Please explain why or why not.

Forgiviness please!

[8 Comments]

Wednesday, October 16, 2024 @ 06:23:16 EDT

« List of pages on this site:

« List of recent entries:

« List of recent comments:

« List of recent links:

« List of random quotes:

"Egotism is the anesthetic that dulls the pain of stupidity."

Frank Leahy (From The Quotations Page.)