From: Mk 27 Date: 2009-05-18T08:43:19+09:00 Subject: Re: permute each element of a ragged array? Phlip wrote: > Rubies: > > Here's a programming chestnut. I suppose I could brute-force my way > through > this, I'm not the kind of person who would already know the answer to this, but I kind of think it is de facto the same as what "brute force" is -- an attempt to cover every possibility. Almost. One optimization that springs to mind immediately would be that if you progress through the array one element at a time and match all possible permutations, eg given 1,2,3 with 1 @ 0: 1 1 1 1 1 1 1 1 1 2 ...etc when doing permutations subsequently with 1 @ 1 you can neglect everything with 1 @ 0. So by the time you reach 1 @ 2, you can limit to 1 2 1 2 1 2 2 1 2 3 1 ...etc One step away from a straight iterative "brute force". -- Posted via http://www.ruby-forum.com/.