Loading...
NikoletaKarachomakova avatar NikoletaKarachomakova 7 Точки

90/100 на задача "Hello France" - Python - Lists Basics

Здравейте,

В Judge не минавам последния тест на тази задача. Пробвах какви ли не тестове, но въпреки това нещо не е наред.

Бихте ли съдействали?

Условието е:

9.* Hello, France

The budget was enough to get them to Frankfurt and they have some money left, but their final aim is to go to France, which means that they will need more finances. They’ve decided to make profit by buying items on discount from the Thrift Shop and selling them for a higher price. You must help them.

Create a program that calculates the profit after buying some items and selling them on a higher price. In order to fulfil that, you are going to need certain data - you will receive a collection of items and a budget in the following format:

{type->price|type->price|type->price……|type->price}

{budget}

The prices for each of the types cannot exceed a certain price, which is given bellow:

Type

Maximum Price

Clothes

50.00

Shoes

35.00

Accessories

20.50

If a price for a certain item is higher than the maximum price, don’t buy it. Every time you buy an item, you have to reduce the budget with the value of its price. If you don’t have enough money for it, you can’t buy it. Buy as much items as you can.

You have to increase the price of each of the items you have successfully bought with 40%. Print the list with the new prices and the profit you will gain from selling the items. They need exactly 150$ for tickets for the train, so if their budget after selling the products is enough – print – "Hello, France!" and if not – "Time to go."

Input / Constraints

  • On the 1st line you are going to receive the items with their prices in the format described above – real numbers in the range [0.00……1000.00]
  • On the 2nd line, you are going to be given the budgeta real number in the range [0.0….1000.0]

Output

  • Print the list with the bought item’s new prices, rounded 2 digits after the decimal separator in the following format:

"{price1} {price2} {price3} {price5}………{priceN}"

  • Print the profit, rounded 2 digits after the decimal separator in the following format:

"Profit: {profit}"

  • If the money for tickets are enough, print: "Hello, France!" and if not – "Time to go."

Examples

Input

Output

Comments

Clothes->43.30|Shoes->25.25|Clothes->36.52|Clothes->20.90|Accessories->15.60

120

60.62 35.35 51.13

Profit: 42.03

Hello, France!

We start subtracting the valid prices from the budget:

120 – 43.40 = 76.7.

76.7 – 25.25 = 51.45

51.45 – 36.52 = 14.93

14.93 is less than 20.90 and 15.60, so we can’t buy either of the last two. We must increase each price with 40% and the new prices are: 60.62 35.35 51.13. The profit is 42.03 and their new budget will be – what is left of the budget - 14.93 + {sum of all newPrices}. It is enough, so we print: Hello, France!

Shoes->41.20|Clothes->20.30|Accessories->40|Shoes->15.60|Shoes->33.30|Clothes->48.60

90

28.42 21.84 46.62

Profit: 27.68

Time to go.

 

 

Това е кодът ми:

https://pastebin.com/5JgH9LPT

Благодаря предварително!

PS: Единственото, за което се сещам е, че би могло да се въведе само една покупка, например "Clothes -> 43.30" и бюджет "20" лв, което означава, че не би могло да се купи и продаде. Съответно няма профит, няма и new price. Пробвах да принтирам 0 и на двете - не става. :(

Тагове:
0
Fundamentals Module 12/06/2020 09:21:01
Atanas_Ivanov avatar Atanas_Ivanov 3 Точки

Здравейте!

Аз не минавам първите два теста в Judge на тази задача.

Моля, ако някой намери грешката, да ме "светне" какво бъркам!

Ето го решението ми:

https://pastebin.com/MeCvVFTT

0
NikoletaKarachomakova avatar NikoletaKarachomakova 7 Точки

Здравей, @Atanas_Ivanov!

Пробвай четвъртия If да го направиш: 

if budget >= product_price:..

а не - if budget > product_price:..

Пробвах го в Judge - даде 100%

Поздрави, 

0
Atanas_Ivanov avatar Atanas_Ivanov 3 Точки

Благодаря! :)

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.