반응형
Numbers ending with zeros are boring.
They might be fun in your world, but not here.
Get rid of them. Only the ending ones.
1450 -> 145
960000 -> 96
1050 -> 105
-1050 -> -105
Zero alone is fine, don't worry about it. Poor guy anyway
Solution:
def remove_zero(func):
def wrapper(n: int):
s = str(n).rstrip("0")
return func(s)
return wrapper
@remove_zero
def no_boring_zeros(s: str):
return s and int(s) or 0
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0906. The Coupon Code (0) | 2022.09.06 |
---|---|
0905. Training JS #7: if..else and ternary operator (0) | 2022.09.05 |
0903. L1: Bartender, drinks! (0) | 2022.09.03 |
0902. Simple multiplication (0) | 2022.09.02 |
0901. Alan Partridge II - Apple Turnover (0) | 2022.09.01 |