randomly selecting objects from an array in O(1)

this python snippet was a fun read:

http://code.activestate.com/recipes/576564-walkers-alias-method-for-random-objects-with-diffe/

(also here in ruby)

Leave a comment