Last active
March 25, 2017 12:36
-
-
Save heisvoid/12f17b7caaa3ac6c22b0 to your computer and use it in GitHub Desktop.
Water charge calculator for Daepyong building.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def cal(usage, homes, table): | |
| charge = 0 | |
| for i, j in table: | |
| assert 0 < i | |
| assert 0 < j | |
| if 0 >= usage: | |
| break | |
| tmp = i * homes | |
| tmp = min(tmp, usage) | |
| charge = charge + j * tmp | |
| usage = usage - tmp | |
| return charge | |
| BASE_CHARGE = 1100 | |
| EXTRA_CHARGE_UNIT = 170 | |
| WATER_TABLE = ((20, 550), (10, 790), (float('inf'), 1210)) | |
| # 2015 | |
| #SEWAGE_TABLE = ((10, 310), (10, 410), (10, 540), (10, 700), (float('inf'), 900)) | |
| # 2016 | |
| #SEWAGE_TABLE = ((10, 420), (10, 550), (10, 730), (10, 950), (float('inf'), 1220)) | |
| # 2017 | |
| SEWAGE_TABLE = ((10, 570), (10, 750), (10, 1000), (10, 1300), (float('inf'), 1680)) | |
| HOMES = 5 | |
| USAGE = 67 | |
| water = cal(USAGE, HOMES, WATER_TABLE) | |
| sewage = cal(USAGE, HOMES, SEWAGE_TABLE) | |
| extra = USAGE * EXTRA_CHARGE_UNIT | |
| total = BASE_CHARGE + water + sewage + extra | |
| print("base: %d" % BASE_CHARGE) | |
| print("water: %d" % water) | |
| print("sewage: %d" % sewage) | |
| print("extra: %d" % extra) | |
| print("total: %d" % total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment