
21 Mar
2009
21 Mar
'09
12:18 a.m.
Yitzchak Gale ha scritto:
Hi Manlio,
Manlio Perillo wrote:
For my Netflix Prize project I have implemented two reusable modules. The first module implements a random shuffle on immutable lists... The second module implements a function used to partition a list into n sublists of random length.
[...]
As you point out, your partition algorithm is not fair. Using your Random.Shuffle and a well-know trick from combinatorics, you can easily get a fair partitions function:
Someone added an alternative implementation: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2485#a2497 Regards Manlio