Задача Exam Shopping
Здравейте, бихте ли ми помогнали с тази задача? Дава ми 55/100 и не знам къде ми е грешката. Наблъсках доста проверки, но няма промяна.
Тук ми е кода: http://pastebin.com/mHEy6rrA
Exam Shopping
A supermarket has products which have quantities. Your task is to stock the shop before Exam Sunday. Until you receive the command “shopping time”, add the various products to the shop’s inventory, keeping track of their quantity (for inventory purposes). When you receive the aforementioned command, the students start pouring in before the exam and buy various products.
The format for stocking a product is: “stock {product} {quantity}”.
The format for buying a product is: “buy {product} {quantity}”.
If a student tries to buy a product, which doesn’t exist, print “{product} doesn't exist”. If it does exist, but it’s out of stock, print “{product} out of stock”. If a student tries buying more than the quantity of that product, sell them all the quantity of the product (the product is left out of stock, don’t print anything).
When you receive the command “exam time”, your task is to print the remaining inventory in the following format: “{product} -> {quantity}”. If a product is out of stock, do not print it.
Examples
Input |
Output |
stock Boca_Cola 10 stock Boca_Cola 10 stock Kay's 3 stock Kay's 2 shopping time buy Boca_Cola 5 buy Kay's 5 exam time |
Boca_Cola -> 15
|
stock Lobster_Energy 20 stock Loreni 30 stock Loreni 30 stock Lobster_Energy 10 shopping time exam time |
Lobster_Energy -> 30 Loreni -> 60 |
stock Boca_Cola 16 stock Kay's_Chips 33 stock Lobster_Energy 60 stock Boca_Cola 4 stock Loreni 15 stock Loreni 15 stock Loreni 15 stock Loreni 15 shopping time buy Boca_Bola 2 buy Lobster_Energy 20 buy Boca_Cola 1 buy Boba_Bola 12 exam time |
Boca_Bola doesn't exist Boba_Bola doesn't exist Boca_Cola -> 19 Kay's_Chips -> 33 Lobster_Energy -> 40 Loreni -> 60 |