+ 2
Code Coach 'Super Sale' 👍 SOLVED
Have somebody solved the 'Super Sale' challenge ? I Don't know what is wrong because all checks are OK except the number 4 Need some help, I can't sleep 😜
25 Answers
0
I only used casting to int on my final result and it worked.
Edit. I just checked yours with int and it works.
+ 3
go get some sleep and come back fresh.. .it's not going to run away... 😉
+ 3
import math
itemsList = [float(s) for s in input().split(",")]
# all except the most expensive item
# get 30% discount
# and the 7% tax as saving
sumForSale = 0.0
DISCOUNT = 0.3
TAX = 1.07
# check if there is more than 1 item to buy
# find and save the most expensive item
# and remove it from the list of items
if(len(itemsList) > 1):
mostExpensiveItem = max(itemsList)
itemsList.remove(mostExpensiveItem)
for item in itemsList:
sumForSale += float(item)
# round to the upper value,
# giving 'decimals' as a tip
print(math.floor(sumForSale * DISCOUNT * TAX))
+ 2
Post your try here.
+ 2
There was no casting/rounding error, only sorting problem between array of strings and array of floats.
Laura Stasiulė see DM
+ 2
I had the same problem with case #4, but I converted all the costs to floats instead of integers and it helped.
+ 1
🌶️alapeño You're welcome.
+ 1
Thank you Mihai Apostol
+ 1
Laura Stasiulė Are you having problems in C# for this challenge?
+ 1
Did you cast your final result to int?
+ 1
I used Math.Floor(mySum)
+ 1
Convert.ToInt32
+ 1
Sorry.
I cannot quite get a hold of it. Post your code here or DM me the code and I will try to help you.
There were a few problems with round/floor/ceil/int... between different languages for the CCC.
+ 1
Sooner or later,I will find out the solution :))
+ 1
My solution:
sum = 0
prices = input().split(",")
prices_of_items = []
for price in prices:
prices_of_items.append(float(price))
for price in prices_of_items:
sum += price
taxed_sales = sum * 1.07
discount_sales = (max(prices_of_items) + (sum - max(prices_of_items)) * 0.7) * 1.07
import math
total_saving = math.floor(taxed_sales - discount_sales)
print(total_saving)
+ 1
Thx
0
Same for me :/
0
Yes,with case number 4... tried to code different ways,but still doesn't work
0
Still doesn't work. I use double,not float,could it be the problem? Tried to check with float,but then there is an error and I gave up :D
0
I guess it's something different,because I tried +1/-1 to see if case 4 would work