Skip to content

Instantly share code, notes, and snippets.

@metruzanca
Created May 11, 2023 18:16
Show Gist options
  • Save metruzanca/4cdccca44e72a7641bbc14e006ecc842 to your computer and use it in GitHub Desktop.
Save metruzanca/4cdccca44e72a7641bbc14e006ecc842 to your computer and use it in GitHub Desktop.
Starting a new job in the middle of a calendar year? Want to max out employer contribution match? Use this.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from datetime import date\n",
"\n",
"salary = int(input('Salary'))\n",
"employerMax = int(input('Contribution % to get max free money'))\n",
"today = date.today()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Assuming paychecks are semi-monthly\n",
"payCycles = 24\n",
"cyclesPerMonth = 2\n",
"remainingPayCycles = payCycles - (today.month - 1) * cyclesPerMonth - (today.day > 15)\n",
"\n",
"print('Remaining pay cycles: ' + str(remainingPayCycles))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"employerContributionTarget = salary * (employerMax/100)\n",
"employeeContributionPerCycle = employerContributionTarget / remainingPayCycles\n",
"employeeContributionPercentage = employeeContributionPerCycle / salary * 100 * 24\n",
"\n",
"\n",
"print(f'Employer contribution per cycle: {employeeContributionPerCycle} - {employeeContributionPercentage}%' )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment