Skip to content

Instantly share code, notes, and snippets.

@kkenny
Created November 19, 2019 21:23
Show Gist options
  • Save kkenny/de99db113d97d3f49a2e857927a9adf2 to your computer and use it in GitHub Desktop.
Save kkenny/de99db113d97d3f49a2e857927a9adf2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import math
price_pro_bar = .7
price_mag = 2.5
tax = .0625
multiplier_pro_bar = 3
budget = 20
unit_cost_stuff = (price_mag + (price_pro_bar * multiplier_pro_bar)) * ((100 - (tax * 100)) / 100)
print("Unit Cost of Stuff: %f"%unit_cost_stuff)
count_stuff_can_buy = budget / unit_cost_stuff
print("I can buy this much stuff: %f"%count_stuff_can_buy)
print("But I can't buy part of a unit, so take the floor to get an integer.")
print("How Much Stuff I can ACTUALLY Buy: %i"%count_stuff_can_buy)
print("But wait, I found this 20% off Coupon, and I've got 5 dollars in my pocket...")
coupon = .2
pocket_cash = 5
new_unit_cost_stuff = ((price_mag + (price_pro_bar * multiplier_pro_bar)) * ((100 - (coupon * 100)) / 100)) * ((100 - (tax * 100)) / 100)
new_count_stuff_can_buy = (budget + pocket_cash) / new_unit_cost_stuff
print("The new unit cost is... %f"%new_unit_cost_stuff)
print("Since I'm thrifty... Now I can buy: %i"%new_count_stuff_can_buy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment