Skip to content

Instantly share code, notes, and snippets.

@cooltoast
Last active August 8, 2022 19:23
Show Gist options
  • Save cooltoast/e9721650708b0018db78d6ad3820720e to your computer and use it in GitHub Desktop.
Save cooltoast/e9721650708b0018db78d6ad3820720e to your computer and use it in GitHub Desktop.
"""
Bitch(es) better have my money.
Instructions:
- Fill in TOTAL, SUBTOTAL, SHARED, and PEOPLE
- Run this script
- Profit
"""
TOTAL = <TOTAL>
SUBTOTAL = <SUBTOTAL>
SHARED = <SHARED>
PEOPLE = dict(
foo=(3 + 8),
bar=(4 + 9),
)
for person, price in PEOPLE.items():
shared_proportion = (SHARED / len(PEOPLE)) / SUBTOTAL
indiv_proportion = (price / SUBTOTAL)
owed = round(shared_proportion * TOTAL + indiv_proportion * TOTAL, 2)
print(f"{person}: ${owed}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment