Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-15 Thread Hugh M
Ah, in the case of looking for all n-digit bit-strings that contain exactly m-1's, the recursive solution is even nicer. Here's how I think of it: Base Case(s): - if you want 0 1's (m==0) then return all 0's. - if you want all 1's (n==m) then return all 1's. Otherwise Recursive Case: - return th

Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-14 Thread Hugh M
The 2**n different lists that you are seeking have a direct association to the binary representation of the integers 0 through (2**n)-1. You can use this fact and the "repeated division method" for converting numbers between different bases to generate these lists and form the desired list of list