You're viewing a single thread.
All comments
129
comments
def even(n: int) -> bool: code = "" for i in range(0, n+1, 2): code += f"if {n} == {i}:\n out = True\n" j = i+1 code += f"if {n} == {j}:\n out = False\n" local_vars = {} exec(code, {}, local_vars) return local_vars["out"]
scalable version
21 0 ReplyNot even else if? Damn, I guess we're checking all the numbers every time then. This is what peak performance looks like
6 0 ReplyO(1) means worst and best case performance are the same.
7 0 Reply
129
comments
Scroll to top