The problem is descried as that, in following snippet, one of the four "ok" test cases is redundant, use boolean algebra and de-morgan law to determine which one.
if (x<3 && y>3)
printf("OK!\n");
else if (x>=3 && y>=3)
printf("OK!\n");
else if (z>3 && x>=3)
printf("OK!\n");
else if (z<=3 && y>=3)
printf("OK!\n");
else
printf("Failed!\n");
so I treated tokens as:
x<3 -> p
y>3 -> q
y>=3 -> m
z>3 -> n
then the problem is equivalent to rule out one of the following four boolean expressions:
p * q
^p * q
n * ^p
^n * m
where p + ^p = 1 and p * ^p = 0, I have no clue how to go further. I think it's because q and m are not independent but I can't figure out another way to do it, any help is appreciated!
Aucun commentaire:
Enregistrer un commentaire