# An implementation of Uber’s "Fare Estimator" [CodeSignal]

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance.

The formula is along the lines of:

``````fare = (cost per minute) * (ride time) + (cost per mile) * (ride distance)
``````

where `ride time` and `ride distance` are constant integers (or floats) and `cost per minute` and `cost per mile` are lists of integers and floats (as cost per minute and cost per mile depend on the car type).

This is my solution:

``````def fareEstimator(ride_time, ride_distance, cost_per_minute, cost_per_mile):
y, f = (), lambda w, x, y, z: (w * x) + (y * z)
for a, b in zip(cost_per_minute, cost_per_mile):
y.append(f(a, ride_time, b, ride_distance))
return y
``````

I’m just looking for any kind of feedback on the code. Is there a better way to implement it? Can you recommend better coding styles? Is my algorithm good or is it a steaming pile of wank? Leave any feedback you want!

You can check out the full challenge here (but you might need to sign up): https://app.codesignal.com/company-challenges/uber/HNQwGHfKAoYsz9KX6