Created
September 18, 2017 14:02
-
-
Save mbrenig/e215e2984e91d2e6b235e9b83eb96aab to your computer and use it in GitHub Desktop.
Profit Share Comparison "Tool"
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
""" | |
profit.py | |
Pair-wise comparison and adjustment of profit share contribution ratios. | |
""" | |
from pprint import pprint | |
import random | |
# Seed this with numbers that are approximately sensible... | |
# The suggested key format is "<Name> (Months in team)" | |
TEAM = { | |
"NewGuy-Fred (5)": 20, | |
"TechLead-Leah (12)": 140, | |
"WorkHorse-Henry (12)": 100, | |
"Tiresome-Terry (12)": 60, | |
"Average-Anne (10)": 70, | |
"Recent-Rebecca": 30, | |
} | |
def compare(): | |
""" The main loop: | |
- Pick a pair of teammates | |
- Display the current contribution comparison | |
- Prompt user to adjust | |
""" | |
first = (None, None) | |
second = (None, None) | |
# Pick two people... | |
first, second = random.sample(list(TEAM.items()), 2) | |
# Sort highest contribution first | |
comp = sorted([first, second], key=lambda x: x[1], reverse=True) | |
(left_name, left_share), (right_name, right_share) = comp | |
pct_diff = (100*float(left_share)/right_share)-100 | |
mlt_diff = float(left_share)/right_share | |
if left_share == right_share or pct_diff < 5: | |
print("In a typical month, {} {:3.2f} contributed about the same as {} {:3.2f}".format( | |
left_name, left_share, right_name, right_share)) | |
elif pct_diff < 100: | |
print("In a typical month, {} contributed {:2.0f}% more than {}".format( | |
left_name, pct_diff, right_name)) | |
else: | |
print("In a typical month, {} contributed {:.2f} times more than {}".format( | |
left_name, mlt_diff, right_name)) | |
print("{} contribution was (h)igher? (l)ower? " | |
"just right (c)ontinue? or (p)rint table?".format(left_name)) | |
choice = input().strip().lower() | |
while choice not in 'hlcp': | |
print("choose: h,l,c or p") | |
choice = input().strip().lower() | |
if choice == 'p': | |
pprint(TEAM) | |
if choice == 'h': | |
TEAM[left_name] = TEAM[left_name] ** 1.02 | |
TEAM[right_name] = TEAM[right_name] ** 0.98 | |
if choice == 'l': | |
TEAM[left_name] = TEAM[left_name] ** 0.98 | |
TEAM[right_name] = TEAM[right_name] ** 1.02 | |
if __name__ == '__main__': | |
while True: | |
compare() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment