[Tutor] combinatorics problem: assembling array
denis.spir at free.fr
Thu Jan 21 14:25:43 CET 2010
On Thu, 21 Jan 2010 10:06:40 +0100
markus kossner <m.kossner at tu-bs.de> wrote:
> Dear Pythonics,
> I have a rather algorithmic problem that obviously made a knot in my brain:
> Assume we have to build up all the arrays that are possible if we have a
> nested array
> containing an array of integers that are allowed for each single
> position. For example
> the nested array
> would define all the arrays of length 3 that can be enumerated using
> array of possible numbers for each position.
> Beforehand I will have no Idea of the length of the arrays. How do I
> enumerate all the possible
> arrays with python?
> Thanks for getting the knot out of my brain,
A loop over first set of numbers, with an inner loop over second set of numbers, with an inner loop over third set of numbers. Deep inside the loops, just feed a list of combinations.
la vita e estrany
More information about the Tutor