Advertisement
eNeRGy90

Untitled

Jan 27th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. travel_types_dict = {}
  2.  
  3. while True:
  4.  
  5.     information = input()
  6.     if information == "ready":
  7.         break
  8.     city = information.split(":")[0]
  9.     travel_types = information.split(":")[1].split(",")
  10.     travel_dict = {}
  11.     if city in travel_types_dict:
  12.         travel_dict = travel_types_dict[city]
  13.  
  14.     for travel_type in travel_types:
  15.         venicle = travel_type.split("-")[0]
  16.         capacity = int(travel_type.split("-")[1])
  17.         travel_dict[venicle] = capacity
  18.  
  19.     travel_types_dict[city] = travel_dict
  20.  
  21.  
  22. while True:
  23.     groups = input()
  24.     if groups == "travel time!":
  25.         break
  26.     total = 0
  27.     city_destination = groups.split()[0]
  28.     people = int(groups.split()[1])
  29.     vehicles = travel_types_dict[city_destination]
  30.  
  31.     for vehickle, capacity in vehicles.items():
  32.         total += capacity
  33.     if people <= total:
  34.         print(f"{city_destination} -> all {people} accommodated")
  35.     else:
  36.         print(f"{city_destination} -> all except {(people - total)} accommodated")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement