반응형
This kata is about multiplying a given number by eight if it is an even number and by nine otherwise.
Solution:
def multiply_factor(func):
def wrapper(n):
return func(n, n%2 and 9 or 8)
return wrapper
@multiply_factor
def simple_multiplication(n: int, m: int) -> int:
return n*m
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0904. No zeros for heros (0) | 2022.09.04 |
---|---|
0903. L1: Bartender, drinks! (0) | 2022.09.03 |
0901. Alan Partridge II - Apple Turnover (0) | 2022.09.01 |
0831. Correct the mistakes of the character recognition software (0) | 2022.08.31 |
0830. Switch it Up! (0) | 2022.08.30 |