Created
October 21, 2023 23:38
-
-
Save tngzng/5516e2107704e0243b7df893113a8e92 to your computer and use it in GitHub Desktop.
This file contains 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
from typing import Union | |
number = Union[float, int] | |
def amt_owed_for_costs(costs: list[number], | |
total: number, | |
tax: number, | |
tip: number, | |
fixed_costs: list[number], | |
num_ppl: int) -> number: | |
''' | |
ex: | |
costs = [10, 12, 18] | |
total = 150 # before tip | |
fixed_costs = [8, 10, 10] # shared costs | |
num_ppl = 3 | |
tax = 13.31 | |
tip = 35 | |
''' | |
base = sum(costs) + ( sum(fixed_costs)/num_ppl ) | |
return base + ( (base/total) * (tax + tip) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment