나는 이렇게 학습한다/Algorithm & SQL

0902. Simple multiplication

daco2020 2022. 9. 2. 23:59
반응형

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


반응형