Ron,
Well, the total number of values is going to be the number of values,
taken to the power of the number of columns that can contain those values.
In this case, it is 2 (number of possible values, true/false) squared (the
number of variables) which gives you four.
If you had three columns, you would have 8 possible combinations.
To represent this in code, you just need a two-dimensional array, like
so, where the first dimension is wich combination of values you want, and
the second column is the actual value in that combination. Using the two
values, three variable approach, you would want an 8x3 array, like so:
int rows = 8;
int columns = 3;
bool[,] matrix = new bool[rows, columns];
To initialize the array, the easiest way to populate it would be to use
a recursive algorithm, as Ignacio suggests.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"RSH" <wa*************@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Okay my math skills aren't waht they used to be...
With that being said what Im trying to do is create a matrix that given x
number of columns, and y number of possible values i want to generate a
two dimensional array of all possible combinations of values.
A simple example:
2 - columns and 2 possible values would generate:
0 0
1 0
0 1
1 1
I obviously need to generate considerably more complex grids but Imagine
the math would be the same.
Thanks for any assistance!
Ron