Search code examples
javalogictruthtable

Minimum number of checks to validate a truth table



I have a java program where I want to validate if any of 3 booleans is false. I want to figure out the smallest expression I can write to check against the permutations.

if(!(needsWork && (needsApproval || isAdmin) ))

I think this is enough to make sure that if any of the 3 booleans is false I want to stop processing. However, I have the sneaking suspicion I am missing something.


Solution

  • Would if (!needsWork || !needsApproval || !isAdmin) not work? Java supports short-circuit evaluation.