generating random tuples in python

bearophileHUGS at bearophileHUGS at
Mon Apr 20 21:21:24 CEST 2009

> in other words i want the list of random numbers to be arbitrarily
> different (which is why i am using rand()) but as different from other
> tuples in the list as possible.

This is more or less the problem of packing n equal spheres in a cube.
There is a lot of literature on this. You can use a simulated
annealing to find good enough solutions. You just need 15 lines of
code or less. But it's going to be slow if n is not very small. A fast
language (or Psyco) is better for that.


More information about the Python-list mailing list