[erlang-questions] Speedy unsort:shuffle/1,2 ?

Johan Montelius johanmon@REDACTED
Thu May 27 16:30:12 CEST 2010


On Thu, 27 May 2010 16:23:03 +0200, Håkan Huss <huss01@REDACTED> wrote:

> If you also add the rule that hitting
> an invalid combination causes the algorithm to restart you will get a
> fair shuffle. However, applying this to an actual algorithm isn't
> necessarily easy. You also lose any deterministic time bounds since
> the algorithm may restart indefinitely).
> Regards,
> /Håkan

Thanks for the explanation. When I first read your comment I thought that  
you meant that we did not have enough coin flips but the problem is of  
course that we use use too many. I realized this when I added a special  
case for shuffling three elements and as you point out I had some cases  
where I had to throw flips away.

   Johan



-- 
Associate Professor Johan Montelius
Royal Institute of Technology - KTH
School of Information and Communication Technology - ICT


More information about the erlang-questions mailing list