Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- city_data = {}
- command = input()
- while command != 'ready':
- vehicles_data = {}
- city_info = command.split(':')
- city = city_info[0]
- vehicles = city_info[1].split(",")
- for item in vehicles:
- vehicle = item.split('-')
- vehicles_data[vehicle[0]] = int(vehicle[1])
- if city not in city_data:
- city_data[city] = vehicles_data
- else:
- city_data[city].update(vehicles_data)
- command = input()
- tourists_data = {}
- command = input()
- while command != 'travel time!':
- tourists_info = command.split(' ')
- tourists_data[tourists_info[0]] = int(tourists_info[1])
- command = input()
- total_vehicles_per_city = {}
- for key, value in city_data.items():
- sum_vehicles = 0
- for val in value.values():
- sum_vehicles += val
- total_vehicles_per_city[key] = sum_vehicles
- for city_name, tourist_value in tourists_data.items():
- for city, vehicles_num in total_vehicles_per_city.items():
- if city_name == city:
- if tourist_value <= vehicles_num:
- print(f'{city} -> all {tourist_value} accommodated')
- else:
- diff = tourist_value - vehicles_num
- print(f'{city} -> all except {diff} accommodated')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement