Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 100/100
- n = int(input())
- car_dict = {}
- for _ in range(n):
- car, mileage, fuel = input().split("|")
- car_dict[car] = {}
- car_dict[car]["Mileage"] = int(mileage)
- car_dict[car]["Fuel"] = int(fuel)
- command = input().split(" : ")
- while command[0] != "Stop":
- action = command[0]
- if action == "Drive":
- car, distance, fuel = command[1], int(command[2]), int(command[3])
- if car in car_dict.keys():
- if fuel > car_dict[car]["Fuel"]:
- print("Not enough fuel to make that ride")
- else:
- car_dict[car]["Mileage"] += distance
- car_dict[car]["Fuel"] -= fuel
- print(f"{car} driven for {distance} kilometers. {fuel} liters of fuel consumed.")
- if car_dict[car]["Mileage"] >= 100000:
- print(f"Time to sell the {car}!")
- del car_dict[car]
- elif action == "Refuel":
- car, fuel = command[1], int(command[2])
- if car in car_dict.keys():
- if car_dict[car]["Fuel"] + fuel <= 75:
- needed_amount = fuel
- else:
- needed_amount = 75 - car_dict[car]["Fuel"]
- car_dict[car]["Fuel"] += needed_amount
- print(f"{car} refueled with {needed_amount} liters")
- elif action == "Revert":
- car, kilometres = command[1], int(command[2])
- if car in car_dict.keys():
- car_dict[car]["Mileage"] -= kilometres
- if car_dict[car]["Mileage"] >= 10000:
- print(f"{car} mileage decreased by {kilometres} kilometers")
- else:
- car_dict[car]["Mileage"] = 10000
- command = input().split(" : ")
- for curr_car, data in car_dict.items():
- total_mileage = data['Mileage']
- fuel_left = data['Fuel']
- print(f"{curr_car} -> Mileage: {total_mileage} kms, Fuel in the tank: {fuel_left} lt.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement