Created
August 3, 2022 23:20
-
-
Save schematis/8f9363bb14d89adfca5cd4dbf0a68801 to your computer and use it in GitHub Desktop.
Calculate macros and calories for Jeff Nippard's recomposition diet plan
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
import math | |
weight_lb = 208.2 # pounds | |
height_in = 72 # inches | |
neck_in = 16.5 # inches | |
waist_in = 44 # inches | |
age = 37 # years | |
deficit_percentage = 20 | |
def __get_calories(): | |
weight_kg = weight_lb / 2.20 | |
height_cm = height_in * 2.54 | |
return round((10 * weight_kg + 6.25 * height_cm - 5 * age + 5) * 1.2 * ((100 - deficit_percentage) / 100)) | |
def __get_body_fat(): | |
return round(86.010 * math.log10(waist_in - neck_in) - 70.041 * math.log10(height_in) + 36.76) | |
def __get_lbm(): | |
return weight_lb - weight_lb * __get_body_fat() / 100 | |
def __get_protein(): | |
point_one_x = 5 | |
point_one_y = 1.6 | |
point_two_x = 30 | |
point_two_y = 1.2 | |
lbm = __get_lbm() | |
body_fat = min(point_two_x, __get_body_fat()) | |
slope = (point_two_y - point_one_y) / (point_two_x - point_one_x) | |
ratio = math.fabs(slope * (point_one_x - body_fat) - point_one_y) | |
return round(ratio * lbm) | |
def __get_fat(): | |
point_one_x = 5 | |
point_one_y = 20 | |
point_two_x = 25 | |
point_two_y = 35 | |
body_fat = min(point_two_x, __get_body_fat()) | |
slope = (point_two_y - point_one_y) / (point_two_x - point_one_x) | |
percentage = round(math.fabs(slope * (point_one_x - body_fat) - point_one_y), 2) | |
return round(percentage / 100 * __get_calories() / 9) | |
def __get_carbs(): | |
protein_cals = __get_protein() * 4 | |
fat_cals = __get_fat() * 9 | |
return round((__get_calories() - protein_cals - fat_cals) / 4) | |
def main(): | |
print(f"Protein: {__get_protein()}g") | |
print(f"Fat: {__get_fat()}g") | |
print(f"Carbs: {__get_carbs()}g") | |
print(f"Calories: {__get_calories()}") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment