Най-задълбочената програма по софтуерно инженерство в България
Loading...
+ Нов въпрос
ralicaterzieva avatar ralicaterzieva 1 Точки

Christmas Spirit

Зравейте, 

не мога да видя отново грешките, които ми връща на задача номер 10 от Python Fundamentals -Basic Syntax Exercise- Christmas Spirit.

Дава ми само 60 процента и до там. Пробвах какво ли не...

Ето и кода ми 

quantity = int(input())
days = int(input())

ornament_set = 2
tree_skirt = 5
tree_garlands = 3
tree_lights = 15

christmas_spirit = 0
budget = 0 

for day in range(1, days+1):
    if day % 11 == 0:
        quantity += 2

    if day % 10 == 0:
        christmas_spirit -= 20
        budget += tree_skirt + tree_lights + tree_garlands

        if day == days:
            christmas_spirit -= 30
        else:
            christmas_spirit += 30  # fifth day with garlands

    if day % 5 == 0:
        christmas_spirit += 17
        budget += tree_lights * quantity
        
    if day % 3 == 0:
        christmas_spirit += 13
        budget += (tree_garlands + tree_skirt) * quantity
        
    if day % 2 == 0:
        christmas_spirit += 5
        budget += ornament_set * quantity

print(f"Total cost: {budget}")
print(f"Total spirit: {christmas_spirit}")

Тагове:
0
Programming Fundamentals
L_Ivanov avatar L_Ivanov 2 Точки

Здравейте,

"If you have bought Tree Skirts and Tree Garlands at the same day you additionally increase your spirit by 30." - реферира към 15-ти ден, а не към 10ти

2рия пример от word файла се е получил верен по случайност.

Ето кода за 100%:

quantity = int(input())
days = int(input())

ornament_set = 2
tree_skirt = 5
tree_garlands = 3
tree_lights = 15

christmas_spirit = 0
budget = 0

for day in range(1, days + 1):
    if day % 11 == 0:
        quantity += 2

    if day % 10 == 0:
        christmas_spirit -= 20
        budget += tree_skirt + tree_lights + tree_garlands

        if day == days:
            christmas_spirit -= 30

    if day % 5 == 0:
        christmas_spirit += 17
        budget += tree_lights * quantity

    if day % 15 == 0:
        christmas_spirit += 30 # fifth day with garlands

    if day % 3 == 0:
        christmas_spirit += 13
        budget += (tree_garlands + tree_skirt) * quantity

    if day % 2 == 0:
        christmas_spirit += 5
        budget += ornament_set * quantity

print(f"Total cost: {budget}")
print(f"Total spirit: {christmas_spirit}")

 

0