+ 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 😜

11th Jan 2020, 3:31 PM
🌶️alapeño
🌶️alapeño - avatar
25 Antworten
0
I only used casting to int on my final result and it worked. Edit. I just checked yours with int and it works.
11th Jan 2020, 9:18 PM
Mihai Apostol
Mihai Apostol - avatar
+ 3
go get some sleep and come back fresh.. .it's not going to run away... 😉
11th Jan 2020, 5:51 PM
laura
+ 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))
11th Jan 2020, 9:01 PM
🌶️alapeño
🌶️alapeño - avatar
+ 2
Post your try here.
11th Jan 2020, 4:28 PM
Mihai Apostol
Mihai Apostol - avatar
+ 2
There was no casting/rounding error, only sorting problem between array of strings and array of floats. Laura Stasiulė see DM
13th Jan 2020, 11:38 AM
Mihai Apostol
Mihai Apostol - avatar
+ 2
I had the same problem with case #4, but I converted all the costs to floats instead of integers and it helped.
29th Sep 2020, 12:46 PM
McInventor29
McInventor29 - avatar
+ 1
🌶️alapeño You're welcome.
11th Jan 2020, 10:01 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Thank you Mihai Apostol
11th Jan 2020, 11:57 PM
🌶️alapeño
🌶️alapeño - avatar
+ 1
Laura Stasiulė Are you having problems in C# for this challenge?
13th Jan 2020, 6:49 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Did you cast your final result to int?
13th Jan 2020, 6:54 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
I used Math.Floor(mySum)
13th Jan 2020, 6:57 AM
Laura Stasiulė
Laura Stasiulė - avatar
+ 1
Convert.ToInt32
13th Jan 2020, 6:59 AM
Mihai Apostol
Mihai Apostol - avatar
+ 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.
13th Jan 2020, 7:30 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Sooner or later,I will find out the solution :))
13th Jan 2020, 9:02 AM
Laura Stasiulė
Laura Stasiulė - avatar
+ 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)
22nd Jun 2021, 4:45 PM
Przemysław Komański
Przemysław Komański - avatar
+ 1
Thx
23rd Jun 2021, 1:34 PM
Przemysław Komański
Przemysław Komański - avatar
0
Same for me :/
13th Jan 2020, 6:39 AM
Laura Stasiulė
Laura Stasiulė - avatar
0
Yes,with case number 4... tried to code different ways,but still doesn't work
13th Jan 2020, 6:51 AM
Laura Stasiulė
Laura Stasiulė - avatar
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
13th Jan 2020, 7:14 AM
Laura Stasiulė
Laura Stasiulė - avatar
0
I guess it's something different,because I tried +1/-1 to see if case 4 would work
13th Jan 2020, 9:00 AM
Laura Stasiulė
Laura Stasiulė - avatar