[Numpy-discussion] Extracting all the possible combinations of a grid
Fri Sep 21 22:47:57 CDT 2007
The pure Pythonic solution is a list comprehension involving multiple sequences:
x = range(0,n)
y = x
z = x
t = [(xx,yy,zz) for xx in x for yy in y for zz in z]
You don't need subscripting, or recursive fns, or Knuth.
Runtime is almost instant (for n=10).
All the NumPy solutions look more painful, so if needs be, transform the NumPy sequences to Python ones.
Can you find the hidden words? Take a break and play Seekadoo!
More information about the Numpy-discussion