Wolfram Science Group
Phoenix, AZ USA
Registered: Aug 2003
In Mathematica, you could just type -
You'd get a list of 531441 lists each 12 long, with each element out of the alphabet 0, 1, 2. The total number comes out that way because that is 3^12.
But it is somewhat easier in a simple case like this to just treat each combination as a 12 digit number in base 3. You are just counting through them, from
So you can get any portion of them and uniquely name each one, as -
With x running from 1 to 531441. (Or to start at the "zeroth" and go to 531440, just remove that -1).
So, say I wanted the first 100. I'd Map that over Range (which just gives a list from 1 to 100), like this -
IntegerDigits[#-1, 3, 12]&/@Range
When I want the next batch I'd just ask for -
IntegerDigits[#-1, 3, 12]&/@Range[101,200]
You can get the whole lot in one go with Tuples, or with a big Range or a Table. But since that is rather large and unwieldy, for most purposes it will be more useful to get each from its integer "name", as above.
Report this post to a moderator | IP: Logged