general: ex3: add solution
This commit is contained in:
parent
e2a6b24076
commit
d755f7b377
22
general/ex3.py
Executable file
22
general/ex3.py
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
def solution(n: int) -> bool:
|
||||
if n < 0:
|
||||
n = -n
|
||||
|
||||
while n:
|
||||
if n % 2 == 1:
|
||||
return False
|
||||
n //= 10
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(solution(0))
|
||||
print(solution(1))
|
||||
print(solution(2468))
|
||||
print(solution(1468))
|
||||
print(solution(-2468))
|
||||
print(solution(-2469))
|
Loading…
Reference in a new issue