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

0829. Holiday VIII - Duty Free

daco2020 2022. 8. 29. 22:21
반응형

The purpose of this kata is to work out just how many bottles of duty free whiskey you would have to buy such that the saving over the normal high street price would effectively cover the cost of your holiday.

You will be given the high street price (normPrice), the duty free discount (discount) and the cost of the holiday.

For example, if a bottle cost £10 normally and the discount in duty free was 10%, you would save £1 per bottle. If your holiday cost £500, the answer you should return would be 500.

All inputs will be integers. Please return an integer. Round down.



Solution:

def discount(func):
    def wrapper(*args):
        return func(args[2], args[0]*(args[1]/100))
    return wrapper

@discount
def duty_free(cost, discount):
    return cost // discount


반응형