SimeonTs

SUPyF2 Basic Exercise - 10. Christmas Spirit

Sep 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.77 KB | None | 0 0
  1. """
  2. Basic Syntax, Conditional Statements and Loops - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Compete/Index/1719#9
  4. Video: https://www.youtube.com/watch?time_continue=4&v=7sHE4HEUqi8
  5.  
  6. SUPyF2 Basic Exercise - 10. Christmas Spirit (not included in final score)
  7.  
  8. Problem:
  9. It's time to get in a Christmas mood. You have to decorate the house in time for the big event,
  10. but you have limited days to do so.
  11. You will receive allowed quantity for one type of decoration and days left until Christmas day to decorate the house.
  12. There are 4 types of decorations and each piece costs a price
  13. • Ornament Set – 2$ a piece
  14. • Tree Skirt – 5$ a piece
  15. • Tree Garlands – 3$ a piece
  16. • Tree Lights – 15$ a piece
  17. Every second day you buy an Ornament Set quantity of times and increase your Christmas spirit by 5.
  18. Every third day you buy Tree Skirts and Tree Garlands (both quantity of times) and increase your spirit by 13.
  19. Every fifth day you buy Tree Lights quantity of times and increase your Christmas spirit by 17.
  20. If you have bought Tree Skirts and Tree Garlands at the same day you additionally increase your spirit by 30.
  21. Every tenth day you lose 20 spirit, because your cat ruins all tree decorations and you have to rebuild the tree and buy
  22. one piece of tree skirt, garlands and lights. That is why you are forced to increase the allowed quantity with 2
  23.  at the beginning of every eleventh day.
  24. Also if the last day is a tenth day the cat decides to demolish even more and ruins the Christmas turkey and you
  25. lose additional 30 spirit.
  26. At the end you must print the total cost and the gained spirit.
  27. Input / Constraints
  28. The input will consist of exactly 2 lines:
  29. • quantity – integer in range [1…100]
  30. • days – integer in range [1…100]
  31. Output:
  32. At the end print the total cost and the total gained spirit in the following format:
  33. • "Total cost: {budget}"
  34. • "Total spirit: {totalSpirit}"
  35. Examples:
  36.  
  37. Input:
  38. 1
  39. 7
  40. Output:
  41. Total cost: 37
  42. Total spirit: 58
  43.  
  44. Input:
  45. 3
  46. 20
  47. Output:
  48. Total cost: 558
  49. Total spirit: 156
  50. """
  51.  
  52. allowed_quantity = int(input())
  53. days = int(input())
  54.  
  55. cost = 0
  56. christmas_spirit = 0
  57.  
  58. for day in range(1, days + 1):
  59.     if day % 11 == 0:
  60.         allowed_quantity += 2
  61.     if day % 2 == 0:
  62.         cost += 2 * allowed_quantity
  63.         christmas_spirit += 5
  64.     if day % 3 == 0:
  65.         cost += 8 * allowed_quantity
  66.         christmas_spirit += 13
  67.     if day % 5 == 0:
  68.         cost += 15 * allowed_quantity
  69.         christmas_spirit += 17
  70.         if day % 3 == 0:
  71.             christmas_spirit += 30
  72.     if day % 10 == 0:
  73.         christmas_spirit -= 20
  74.         cost += 23
  75.     if day == days and day % 10 == 0:
  76.         christmas_spirit -= 30
  77.  
  78. print(f"Total cost: {cost}")
  79. print(f"Total spirit: {christmas_spirit}")
Add Comment
Please, Sign In to add comment