top of page
  • Trae Bailey

Short-Circuit Boolean Evaluator

I recently ran across a four-year-old cover letter that had an attached assignment from the prospective employer. It was a Unity Programmer position and had a simple prompt (which I failed to follow the instructions to at the time). Today I will talk about what I did wrong and how I would approach the problem differently now. First, let’s present the prompt.


Describe the steps a short-circuit Boolean evaluator would use to evaluate the following expression and write the final value as TRUE or FALSE:


Let apples = 5, bananas = 6, isSmiling = FALSE.

isSmiling || (apples > 5 && bananas <= 6 && !isSmiling) = ?


So this may seem like a very simple problem to solve. That turned out to be true and I got the final value correct. So how did I fail to follow the instructions?

First off, I had no idea what a short-circuit Boolean evaluator even was (I wasn’t a CS major). I had access to the internet but figured that, as long as I could get the result correct, I didn’t need to know. Wrong. Knowing how that specific evaluator worked was key in describing the steps.


Second, I described the steps with little explanation and most of it was expressed using Boolean algebra. This was the part I think I lost all of my pending credibility on. I should have first looked up ‘short-circuit Boolean evaluator’ and then read the prompt again to understand exactly what they wanted to see. It is mainly a test of comprehension and attention to detail.

Wikipedia currently defines short-circuit evaluation as: “...the semantics of some Boolean operators in some programming languages in which the second argument is executed or evaluated only if the first argument does not suffice to determine the value of the expression...”.


Knowing all of that information would now lead me to an answer like this:


“The short-circuit Boolean evaluator would first take reference of the variables and plug them into the expression. Since the first argument (left side) is clearly FALSE, and is connected via OR gate to the second argument, the right side of the expression should now be evaluated. The second argument can be divided into three smaller sections and each is connected via AND gates. This means that, if ANY of the arguments are determined to be FALSE, then the right side of the expression is FALSE. The first section of this interdependent argument (‘apples > 5’ or ‘5 > 5’ when plugged in) would evaluate to FALSE as five is NOT greater than itself. This effectively forces the second argument (entire right side of the expression) to be FALSE. Since both sides of the OR gate are now FALSE, the final value is also FALSE.”


Lesson learned: Thoroughly understand what question is being asked and the problem that needs to be solved. Also, take each problem seriously - even if it looks to be trivial at first.

314 views0 comments
bottom of page