Advertisement
AlexNedyalkov

Untitled

Jan 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. import math
  2. dictionary_shells = {}
  3. while True:
  4.     input_string = input()
  5.     if input_string == "Aggregate":
  6.         break
  7.     input_list = input_string.split()
  8.  
  9.     region = input_list[0]
  10.     size = [int(input_list[1])]
  11.  
  12.  
  13.     if region in dictionary_shells:
  14.         if size[0] in dictionary_shells[region]:
  15.             continue
  16.         else:
  17.             dictionary_shells[region].append(size[0])
  18.     else:
  19.         dictionary_shells[region] = size
  20.  
  21. for region in dictionary_shells:
  22.     sum = 0
  23.  
  24.     for size in dictionary_shells[region]:
  25.         sum = sum + size
  26.  
  27.     average = sum/len(dictionary_shells[region])
  28.     if len(dictionary_shells[region]) == 1:
  29.         giantshell = sum
  30.     elif len(dictionary_shells[region]) > 1:
  31.         giantshell = sum - average
  32.  
  33.     print(f"{region} -> ", end ="")
  34.     print(*dictionary_shells[region], sep=", ", end ="")
  35.     print(f" ({math.ceil(giantshell)})")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement