"Angry Professor" Python implementation
def class_cancelled(expected, arrival_times):
    ....
    return actual &gt;= expected

print "NO" if class_cancelled(K, A) else "YES"


class_cancelled is a misnomer. It in fact computes a class_not_cancelled condition: class should be cancelled when actual &lt; expected. Also the problem asks to print "Yes" when the class gets cancelled. Funny how two wrongs make it right.