Skip to content

Instantly share code, notes, and snippets.

@tngzng
Created October 21, 2023 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tngzng/5516e2107704e0243b7df893113a8e92 to your computer and use it in GitHub Desktop.
Save tngzng/5516e2107704e0243b7df893113a8e92 to your computer and use it in GitHub Desktop.
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