diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2017-10-27 17:27:11 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2017-11-09 16:50:41 +0100 |
| commit | 8aa41f02c4c56a4e17db4ba2d51bc251e9c97982 (patch) | |
| tree | 23bcd2f23765ed415f33d12f19f615fdb8721107 /tanken.py | |
| parent | f07c7625327104eb8ff58d6c4cae173904338a65 (diff) | |
| download | geldschieberbot-8aa41f02c4c56a4e17db4ba2d51bc251e9c97982.tar.gz geldschieberbot-8aa41f02c4c56a4e17db4ba2d51bc251e9c97982.zip | |
add tanken feature
Diffstat (limited to 'tanken.py')
| -rw-r--r-- | tanken.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tanken.py b/tanken.py new file mode 100644 index 0000000..4685fee --- /dev/null +++ b/tanken.py @@ -0,0 +1,25 @@ +#!/bin/env python3 + +def tanken(drives, cost): + passagers = {} + distance = 0. + + for d in drives: + try: + distance += int(d[0]) + except: + return None, "Lines have to start with the driven distance!" + for p in d[1:]: + if p not in passagers: + passagers[p] = [int(d[0]),0] + else: + passagers[p][0] += int(d[0]) + + c = cost/distance + + for d in drives: + c_d = c * int(d[0]) / (len(d) - 1) + for p in d[1:]: + passagers[p][1] += c_d + + return passagers, None |
