Created
March 26, 2012 20:03
-
-
Save Klowner/2209264 to your computer and use it in GitHub Desktop.
A script to generate increments for weight training
This file contains 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
#!/usr/bin/env python | |
from decimal import Decimal | |
def fiveround(x): | |
return Decimal(int(5 * round(float(x)/5))) | |
def simplify(x): | |
result = [] | |
curr_x = x | |
items = map(lambda x:Decimal(x), [45,35,25,10,5,2.5]) | |
for i in items: | |
if curr_x >= i: | |
result.append(i) | |
curr_x -= i | |
return result | |
def increments(total, base, steps): | |
total = Decimal(total) | |
base = Decimal(base) | |
x = total - base | |
x = x / Decimal(steps) | |
for i in range(0,steps+1): | |
amt = Decimal(x*i) | |
parts = simplify(amt/Decimal(2)) | |
amt = sum(parts)*Decimal(2) | |
yield (base + amt, amt, parts) #simplify(amt/Decimal(2))) | |
def pretty(total, base, steps): | |
print "Total\tPlus\t\tWeights" | |
print "-----\t----\t\t-------" | |
for (total,extra,parts) in increments(total, base, steps): | |
parts ='\t'.join(map(lambda x:str(x), parts)) | |
print "%s\t%s\t\t%s" % (total, extra, parts) | |
if __name__ == '__main__': | |
import argparse | |
parser = argparse.ArgumentParser(description="Calculate Starting Strength weight increments") | |
parser.add_argument('base', type=int, help="Base (bar) weight") | |
parser.add_argument('goal', type=int, help="Final working weight") | |
parser.add_argument('steps', type=int, nargs='?', default=4, help="Number of increments to reach final weight (default: 4)") | |
args = parser.parse_args() | |
pretty(args.goal, args.base, args.steps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment