We want to implement an income calculator that,
given a compensation package and start date,
returns the income per year until the present.
The input is:
Start date (SimpleDate)
Base salary per year(int)
RSU per year (int)
Sign on bonus, only once (int)SimpleDate is my own implementation of Date. It has these fields:
SimpleDate:
month: int
year: intYou can also use SimpleDate.now() to get the current date.
Example: Given these values
Base salary: 120,000
RSU: 60,000
Sign on: 25,000
Start date: 02/2018
Current date 02/2020
The calculator should return:
2018: 190,000 (11 months income, including February plus sign on)
2019: 180,000 (12 months income)
2020: 15,000 (only January, excluding February)
My Proposed Solution -
def income_calculator(start_date, base_salary, rsu, sign_on):
current_date = SimpleDate.now()
start = start_date.year
mp = {}
salary_p_month = base_salary//12
rsu_p_month = rsu//12
if start == current_date.year:
n_month = current_date.month - start_date.month
fisrt_income = salary_p_month*n_month + rsu_p_month*n_month + sign_on
mp[start] = first_income
return mp
else:
n_month = 12 - start_date.month + 1
fisrt_income = salary_p_month*n_month + rsu_p_month*n_month + sign_on
mp[start] = first_income
start += 1
while current_date.year != start:
income = 12*(salary_p_month + rsu_p_month)
mp[start] = income
start += 1
income = (current_date.month - 1)*(salary_p_month + rsu_p_month)
mp[start] = income
return mpAny feedbacks and suggestions will be highly appreciated.
I got rejected, but I feel good that I was able to solve all the questions that was asked in 3 rounds of onsites.
Also for those who feel bad about rejection ,
Rejection is just a redirection to something better that has to come to you.