I have a situation where I need users to determine solutions based on the number of specified conditions. For example, my program should automatically generate a matrix, as shown below, that there are two conditions (IsMale and IsSmoker):
IsMale: YES YES NO NO
IsSmoker: YES NO YES NO
And the definition is user-defined, so any of the following can be done:
IsMale: YES YES NO NO
IsSmoker: YES NO YES NO
Decision: T F T F
IsMale: YES YES NO NO
IsSmoker: YES NO YES NO
Decision: F F F F
IsMale: YES YES NO NO
IsSmoker: YES NO YES NO
Decision: T T T T
There can be only two states for each condition: True and False . Thus, the total number of combinations is calculated as follows:
there are no possible states (S) for power no from conditions (C) S ^ C = total number of combinations
4 possibilities (2 ^ 2 = 4)
Condition A T T F F
Condition B T F T F
8 possibilities (2 ^ 3 = 8)
Condition A T T T T F F F F
Condition B T T F F T F T F
Condition C T F T F T T F F
, .
:
Guffa. .
4 possibilities (2^2=4)
index = 0, ( 0)
binary 8 4 2 1 Value
original 0 0 0 1 1
& 1 0 0 0 1 1 T
original 0 0 1 0 2
& 1 0 0 0 1 0 F
original 0 0 1 1 3
& 1 0 0 0 1 1 T
original 0 1 0 0 4
& 1 0 0 0 1 0 F
index = 1, ( 1)
binary 8 4 2 1 Value
original 0 0 0 1 1
shift 0 0 0 0 0
& 1 0 0 0 1 0 F
original 0 0 1 0 2
shift 0 0 0 1 1
& 1 0 0 0 1 1 T
original 0 0 1 1 3
shift 0 0 0 1 1
& 1 0 0 0 1 1 T
original 0 1 0 0 4
shift 0 0 1 0 2
& 1 0 0 0 1 0 F
< > :
Condition 1: TFTF
Condition 2: FTTF