SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data = input()
  2.  
  3. city_dict = {}
  4. trans_dict = {}
  5.  
  6. while data != 'ready':
  7.     city = data.split(":")[0]
  8.     transportation_list = data.split(":")[1].split(",")
  9.     if city not in city_dict:
  10.         city_dict.update({city: trans_dict})
  11.         trans_dict = {}
  12.         for items in transportation_list:
  13.             vehicle = items.split("-")[0]
  14.             vehicle_count = int(items.split("-")[1])
  15.             city_dict[city].update({vehicle: vehicle_count})
  16.     else:
  17.         trans_dict = {}
  18.         for items in transportation_list:
  19.             vehicle = items.split("-")[0]
  20.             vehicle_count = int(items.split("-")[1])
  21.             city_dict[city].update({vehicle: vehicle_count})
  22.     data = input()
  23.  
  24. data = input()
  25.  
  26. total = 0
  27.  
  28. while data != 'travel time!':
  29.     city = data.split(" ")[0]
  30.     passengers = int(data.split(" ")[1])
  31.     for key, value in city_dict.items():
  32.         if key == city:
  33.             for key2, value2 in value.items():
  34.                 total += value2
  35.     if total >= passengers:
  36.         print(f'{city} -> all {passengers} accommodated')
  37.     else:
  38.         print(f'{city} -> all except {passengers-total} accommodated')
  39.     total = 0
  40.     data = input()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top