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.

Revisions

  1. sputnikus created this gist Oct 14, 2018.
    63 changes: 63 additions & 0 deletions to_be_a_beast.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    #!/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()