I have an array of strings, can be any length. How can I produce a boolean matrix (array of array of boolean values with the same width as the array of strings) that contains all combinations of booleans?
Result should look something like this
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
.
.
1 1 1 1
Edit: To elaborate a little, this is part of a solution to a larger problem to generate dynamic SQL to handle where clause conditions across multiple tables each with 2 versions. In my attempt to narrow down the issue I agree I might have been too terse, I apologize.
This is what I ended up doing with the help of JamJar00.
var sWhere = TranslateCriteriaToSQL(oUoW, oCriteria, false, false, DataBaseID, User);
var sResult = "";
var tables = asTables.ToArray();
int n = tables.Length;
List<bool[]> matrix = new List<bool[]>();
double count = Math.Pow(2, n);
for (int i = 0; i < count; i++)
{
string str = Convert.ToString(i, 2).PadLeft(n, '0');
bool[] boolArr = str.Select((x) => x == '1').ToArray();
var sCondition = sWhere;
for (var j = 0; j < boolArr.Length; j++)
{
if (boolArr[j])
{
sCondition = " OR (" + sCondition.Replace("[" + tables[j] + "]", "[" + tables[j] + "Pending" + "]") +
")\n";
}
}
sResult += sCondition;
}
}