I have this following logic which needs simplifing to look clearer and consise:
if (x1 < y1)
return 1;
else if (x1 == y1)) {
if (x2 < y2)
return 1;
else if (x2 == y2) {
if (x3 < y3)
return 1;
} else
return 0;
}
} else
return 0;
In order to solve this above problem, I have applied logical expressions to further simplify these few lines of conditions:
if (x1 < y1 || (x1 == y1 && x2 < y2) || (x1 == y1 && x2 == y2 && x3 < y3))
return 1;
else
return 0;
I am not sure how to simplify further from here. Can anyone help me?
Update: For further simplifying, I tried applying boolean algebra to this expression, but no luck! I have come up with this:
A + (A1 * B) + (A1 * B1 * C)
Where A
denotes to x1 < y1
and A1
denotes to x1 == y2