I'm asking this question in the context of a program I'm trying to write, but the problem I'm having seemed to be more of a mathematical one. (Also, I'm not quite sure what tags should be applied to this question, so please feel free to edit them.)
I'm trying to figure out how to compute the number of possibilities in a given set of numbers, where certain number "bits" or "slots" can be binary, while others can be trinary.
First of all I know that I can do this:
If I have say, two "bits".
00 And I know I can put two values into them:
1 or 0
The possible combinations are:
00, 01, 10, 11
Or four possibilities.
I can compute this beforehand by raising the number of spaces to the number of possibilities. (i.e. 2 to the 2nd (2^2)) If I had three "bits", it would be 3 to the 2nd (3^2) giving us nine possibilities. If I had four "bits" I could raise 4 to the second, and so on.
Now my question is this:
How do I compute a value where certain of the spaces (or "bits) are binary while others are trinary or even higher. For example:
Where one "bit" or slot can have a value of either 1 or 0
Slot 2 can be either 1 or 0 or 2
00, 01, 02, 10, 11, 12 are all of the possibilities.
In what way would I be able to calculate the number of possibilities beforehand?