Created
June 8, 2009 22:21
-
-
Save tav/126104 to your computer and use it in GitHub Desktop.
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
from decimal import Decimal | |
def profit(price, current, bid_increase=Decimal('0.15'), bid_price=Decimal('0.75')): | |
price, current = Decimal(price), Decimal(current) | |
bids = current / bid_increase | |
total = (bids * bid_price) | |
if current < price: current = 0 | |
profit = total - price + current | |
# print "# of bids:", bids | |
# print "profit:", profit | |
return profit | |
def penny(price, current): return profit(price, current, Decimal('0.01')) | |
def profit_uk(price, current): return profit(price, current, Decimal('0.07'), Decimal('0.50')) | |
def penny_uk(price, current): return profit(price, current, Decimal('0.01'), Decimal('0.50')) | |
def find_profit(penny_auction=False): | |
if penny_auction: | |
bid_increase = Decimal('0.01') | |
else: | |
bid_increase = Decimal('0.15') | |
current = raw_input('Current Price: ') | |
price = raw_input('Product Price: ') | |
return profit(price, current, bid_increase) | |
def find_profit_uk(penny_auction=False): | |
if penny_auction: | |
bid_increase = Decimal('0.01') | |
else: | |
bid_increase = Decimal('0.07') | |
current = raw_input('Current Price: ') | |
price = raw_input('Product Price: ') | |
return profit(price, current, bid_increase, Decimal('0.50')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment