Advertisement
aneliabogeva

10. Shellbound

Jul 8th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import math
  2.  
  3. command = input()
  4. shells_area = {}
  5. new_dict = {}
  6. result = 0
  7.  
  8. while not command == "Aggregate":
  9. city, shell_size = [item for item in command.split(" ")]
  10. if not city in shells_area:
  11. shells_area[city] = [shell_size]
  12. else:
  13. if shell_size not in shells_area[city]:
  14. shells_area[city].append(shell_size)
  15. sum_shells = sum(list(map(int, shells_area[city])))
  16. count_shells = len(shells_area[city])
  17.  
  18. result_shels = math.ceil(sum_shells -(sum_shells / count_shells))
  19. new_dict[city] = result_shels
  20. command = input()
  21.  
  22. for key, value in shells_area.items():
  23. print(f"{key} -> {', '.join(value)} ({new_dict[key]})")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement