0

# Super Sale Problem

QUESTION PROMPT: Your favorite store is having a sale! You pay full price for the most expensive item that you get, but then you get 30% off of everything else in your purchase! How much are you going to save? Sales tax is 7%. Also, you leave anything below a dollar in your saving as a tip to the seller. If your saving is a round amount, you don't leave any tips. I CAN SOLVE 6/7 TEST CASES (FAILING TEST CASE 4). WHATS WRONG? https://code.sololearn.com/cemz9c964iGD/?ref=app

4 Answers

+ 6

Having looked again at your code, I realised the problem could be in your finding of the orice of the most expensive item. You don't change the prices to ints until after you find the p_max, so you've only compared the strings of the prices.
That means that if you had an item at "12" and another at "5", it would take "5" to be the greater price. Also, you may run into problems if there are two items with equal maximum price as I think you would still get 30% of the second maximum-priced item.

+ 3

I realized I should of been converting the string to a float not an integer! that was messing up the calculations. thanks for the help

+ 3

items = sorted(list(map(float, input().split(","))))
taxed = [i * 1.07 for i in items]
discounted = [i *.3 for i in taxed[:-1]]
savings = int(sum(discounted)//1)
print(savings)

+ 2

Try changing
print(math.floor(total*1.07))
to
print(round(total*1.07, 2)).
I'm sure it's just a rounding error.