You must log in or # to comment.
import re def is_even(i: int) -> bool: return re.match(r"-?\d*[02468]$", str(i)) is not Nonei was gonna suggest the classic
re.match(r"^(..)\1*$", "0" * abs(i)) is not None
return trueis correct around half of the time
return Math.random() > 0.5would also be correct about half the time
assert IsEven(2) == True assert IsEven(4) == True assert IsEven(6) == TrueAll checks pass. LGTM
If number%2 == 0: return("Even") Else: return("odd")Not all ARM CPUs support mod operations. It’s better to use bit operations. Check if the last bit is set. If set it’s odd else it’s even.





