Професионална програма
Loading...
dunedanetz avatar dunedanetz 5 Точки

Въпрос относно Conditional Statements - Lab - 08-Toy Shop

Здравейте, Реших задачата за Toy Shop, като в PyCharm всичко е точно, но като я пусна в judge ми дава само 60/100. Гледах, гледах, не успях да намеря пробрем. Пускам тук моето решение, за да може някой ако види проблемът, да ме светне :)

trip_cost = float(input())
puzzle_count = int(input())
talking_doll = int(input())
teddy_bear = int(input())
minnions = int(input())
trucks = int(input())

total_count = puzzle_count + talking_doll + teddy_bear + minnions + trucks
combined_purchase = (puzzle_count*2.60) + (talking_doll*3) + (teddy_bear*4.10) + (minnions*8.20) + (trucks*2)
discount = (combined_purchase*25)/100

if total_count < 50:
    rent2 = ((combined_purchase*10)/100)
    total2 = combined_purchase - rent2
    if total2 < trip_cost:
        money_left2 =(trip_cost - total2)
        final2 = round(money_left2, 2)
        print('Not enough money! {0} lv needed.'.format(final2))
    elif total2 >= trip_cost:
        money_left3 = (total2 - trip_cost)
        final3 = round(money_left3, 2)
        print('Yes! {0} lv left.'.format(final3))
elif total_count >= 50:
    discounted_price = combined_purchase - discount
    rent = (discounted_price*10)/100
    total = discounted_price - rent
    if total >= trip_cost:
        money_left = (total - trip_cost)
        final = round(money_left, 2)
        print('Yes! {0} lv left.'.format(final))
    elif total < trip_cost:
        money_left4 = (trip_cost - total)
        final4 = round(money_left4, 2)
        print('Not enough money! {0} lv needed.'.format(final4))
Тагове:
1
Programming Basics with Python 28/04/2020 17:45:00
Vikadie avatar Vikadie 2 Точки

Здравей,

Ето и моето решение, което е минало през Judge:

excursion = float(input())
num_puzzles = int(input())
num_speaking_dolls = int(input())
num_teddy_bear = int(input())
num_minion = int(input())
num_truck = int(input())

puzzle = 2.6
speaking_doll = 3
teddy_bear = 4.1
minion = 8.2
truck = 2

number = num_minion + num_puzzles + num_speaking_dolls + num_teddy_bear + num_truck
if number >= 50:
    discount = 0.25
else:
    discount = 0

turnover = (puzzle * num_puzzles + speaking_doll * num_speaking_dolls + teddy_bear * num_teddy_bear + num_minion * minion + truck * num_truck) * (1 - discount)
profit = turnover * 0.9

if profit >= excursion:
    print(f"Yes! {(profit - excursion):.2f} lv left.")
else:
    print(f"Not enough money! {(excursion - profit):.2f} lv needed.")

 

1