Skip to content

Instantly share code, notes, and snippets.

@sputnikus
Created October 14, 2018 09:54
Show Gist options
  • Save sputnikus/2dc7e7465ed69747bc1aaca78284903f to your computer and use it in GitHub Desktop.
Save sputnikus/2dc7e7465ed69747bc1aaca78284903f to your computer and use it in GitHub Desktop.
Macro calculation based on the To Be a Beast article https://www.barbellmedicine.com/584-2/ by Jordan Feigenbaum
#!/usr/bin/env python
import enum
from math import ceil
import click
MALE = "male"
FEMALE = "female"
CUT = "cut"
MAINTAIN = "maintain"
BULK = "bulk"
MACROS = {
MALE : {
CUT: {
"protein": 1.25,
"carbs": 1,
"fat": 0.27
},
MAINTAIN: {
"protein": 1.15,
"carbs": 1.25,
"fat": 0.35
},
BULK: {
"protein": 1.1,
"carbs": 2,
"fat": 0.5
}
},
FEMALE: {
CUT: {
"protein": 1.15,
"carbs": 0.9,
"fat": 0.35
},
MAINTAIN: {
"protein": 1.1,
"carbs": 1.2,
"fat": 0.38
},
BULK: {
"protein": 1,
"carbs": 1.6,
"fat": 0.5
}
},
}
@click.command()
@click.option("--weight", "-w", help="Weight in pounds", type=click.INT, prompt=True)
@click.option("--gender", "-g", help="Person's gender", type=click.Choice((MALE, FEMALE)), prompt=True)
@click.option("--mode", "-m", help="Weight administration regime", type=click.Choice((CUT, MAINTAIN, BULK)), prompt=True)
def main(weight, gender, mode):
config = MACROS[gender][mode]
print("Counted macros for {}ing:".format(mode))
for macro in config:
print("\t{macro}: {amount:d} grams".format(macro=macro, amount=ceil(weight*config[macro])))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment