-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMost Cost Efficient Car.py
27 lines (24 loc) · 1.13 KB
/
Most Cost Efficient Car.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from os import *
from sys import *
from collections import *
from math import *
'''
--------------------------- Car class for reference ---------------------------
class Car:
def __init__(self,priceOfCar,maintenanceCostPerMonth,numberOfkilemeterCarRunInOneLiter,pricePerLiter,numberOfKilometerCarRunInaMonth):
self.priceOfCar=priceOfCar
self.maintenanceCostPerMonth=maintenanceCostPerMonth
self.numberOfkilemeterCarRunInOneLiter=numberOfkilemeterCarRunInOneLiter
self.pricePerLiter=pricePerLiter
self.numberOfKilometerCarRunInaMonth=numberOfKilometerCarRunInaMonth
'''
def mostCostEfficientCar(petrolCar, dieselCar):
A=petrolCar.priceOfCar+petrolCar.maintenanceCostPerMonth*6+petrolCar.pricePerLiter/petrolCar.numberOfkilemeterCarRunInOneLiter*petrolCar.numberOfKilometerCarRunInaMonth*6
B=dieselCar.priceOfCar+dieselCar.maintenanceCostPerMonth*6+dieselCar.pricePerLiter/dieselCar.numberOfkilemeterCarRunInOneLiter*dieselCar.numberOfKilometerCarRunInaMonth*6
if A>B:
return 1
if A==B:
return -1
return 0
# Write your code here.
pass