What is the simplest way to compare truthiness in this specific way?

Given the following instructions I have created a function that achieves the requirements. I feel my function is a bit too complex, though it does what it’s supposed to. The difficult part for myself …