반응형
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
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0831. Correct the mistakes of the character recognition software (0) | 2022.08.31 |
---|---|
0830. Switch it Up! (0) | 2022.08.30 |
0828. Basic Mathematical Operations (0) | 2022.08.28 |
0827. Sum Arrays (0) | 2022.08.27 |
0826. A wolf in sheep's clothing (0) | 2022.08.26 |