Advertisement
go6odn28

need_for_speed_III_100/100

Mar 24th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. # 100/100
  2.  
  3. n = int(input())
  4. car_dict = {}
  5. for _ in range(n):
  6.     car, mileage, fuel = input().split("|")
  7.     car_dict[car] = {}
  8.     car_dict[car]["Mileage"] = int(mileage)
  9.     car_dict[car]["Fuel"] = int(fuel)
  10.  
  11. command = input().split(" : ")
  12. while command[0] != "Stop":
  13.     action = command[0]
  14.     if action == "Drive":
  15.         car, distance, fuel = command[1], int(command[2]), int(command[3])
  16.         if car in car_dict.keys():
  17.             if fuel > car_dict[car]["Fuel"]:
  18.                 print("Not enough fuel to make that ride")
  19.             else:
  20.                 car_dict[car]["Mileage"] += distance
  21.                 car_dict[car]["Fuel"] -= fuel
  22.                 print(f"{car} driven for {distance} kilometers. {fuel} liters of fuel consumed.")
  23.                 if car_dict[car]["Mileage"] >= 100000:
  24.                     print(f"Time to sell the {car}!")
  25.                     del car_dict[car]
  26.     elif action == "Refuel":
  27.         car, fuel = command[1], int(command[2])
  28.         if car in car_dict.keys():
  29.             if car_dict[car]["Fuel"] + fuel <= 75:
  30.                 needed_amount = fuel
  31.             else:
  32.                 needed_amount = 75 - car_dict[car]["Fuel"]
  33.             car_dict[car]["Fuel"] += needed_amount
  34.             print(f"{car} refueled with {needed_amount} liters")
  35.     elif action == "Revert":
  36.         car, kilometres = command[1], int(command[2])
  37.         if car in car_dict.keys():
  38.             car_dict[car]["Mileage"] -= kilometres
  39.             if car_dict[car]["Mileage"] >= 10000:
  40.                 print(f"{car} mileage decreased by {kilometres} kilometers")
  41.             else:
  42.                 car_dict[car]["Mileage"] = 10000
  43.  
  44.     command = input().split(" : ")
  45.  
  46. for curr_car, data in car_dict.items():
  47.     total_mileage = data['Mileage']
  48.     fuel_left = data['Fuel']
  49.     print(f"{curr_car} -> Mileage: {total_mileage} kms, Fuel in the tank: {fuel_left} lt.")
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement