Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- travel_types_dict = {}
- while True:
- information = input()
- if information == "ready":
- break
- city = information.split(":")[0]
- travel_types = information.split(":")[1].split(",")
- travel_dict = {}
- if city in travel_types_dict:
- travel_dict = travel_types_dict[city]
- for travel_type in travel_types:
- venicle = travel_type.split("-")[0]
- capacity = int(travel_type.split("-")[1])
- travel_dict[venicle] = capacity
- travel_types_dict[city] = travel_dict
- while True:
- groups = input()
- if groups == "travel time!":
- break
- total = 0
- city_destination = groups.split()[0]
- people = int(groups.split()[1])
- vehicles = travel_types_dict[city_destination]
- for vehickle, capacity in vehicles.items():
- total += capacity
- if people <= total:
- print(f"{city_destination} -> all {people} accommodated")
- else:
- print(f"{city_destination} -> all except {(people - total)} accommodated")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement