aboutsummaryrefslogtreecommitdiff
path: root/tanken.py
diff options
context:
space:
mode:
Diffstat (limited to 'tanken.py')
-rw-r--r--tanken.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/tanken.py b/tanken.py
index b7064cd..19d65c7 100644
--- a/tanken.py
+++ b/tanken.py
@@ -1,5 +1,6 @@
#!/bin/env python3
+
# cost should be given in cents
def tanken(drives, cost, service_charge=0):
passengers = {}
@@ -19,17 +20,19 @@ def tanken(drives, cost, service_charge=0):
# collect distances per passenger
for p in d[1:]:
if p not in passengers:
- passengers[p] = {"distance": d[0],
- "cost": 0,
- "service_charge": 0}
+ passengers[p] = {
+ "distance": d[0],
+ "cost": 0,
+ "service_charge": 0
+ }
else:
passengers[p]["distance"] += d[0]
-
+
# calculate cost per kilometer
if distance <= 0:
return None, "Driven distance must be greater than 0!"
- c = cost/distance
+ c = cost / distance
for d in drives:
# calculate cost per drive split among passengers