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