How can you express X of Y are true, in boolean logic? a rule like 2 of the following must be true (A, B, C, D, E, F)
is it a form of multiplcation or set operations?
the end result is all the permutations like AB OR AC OR AD, if you said 3 of following it is like ABC, ABD, ABE, etc.. so it is like (A,B,C)^2?
thanks!
In boolean logic (v is OR, ' following the predicate is NOT):
A B C'D'E'F' v
A B'C'D'E'F v
A'B C'D'E'F' v
: : : : : :
<absolute bucketload of boolean expressions>
: : : : : :
A'B'C'D'E F
With permutations, there's a great many subexpressions you need to write.
Of course, if this is a programming question, you could just convert the booleans to 0 or 1, add them all up and ensure the result is 2.
Assuming C# or some other language where bool != int:
bool nOf(int n, bool[] bs)
{
foreach(bool b in bs)
{
if((n -= b ? 1 : 0) <= 0) break;
}
return n == 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With