The bug in the random sort
March 5, 2020We needed to randomize a list of values, so I quickly wrote the following code:
What do you expect the output to be?
A –> 2431
B –> 2571
C -> 4998
The number vary slightly, but they are surprisingly consistent overall. C is about 50% likely to be at the head of the list, but I wanted the probability to be 33% obviously.
Can you figure out…