Created
May 31, 2014 02:36
-
-
Save falconair/9645dda18e9fecd58a84 to your computer and use it in GitHub Desktop.
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
''' | |
Tool to calculate warmup sets and which plates should be placed on the barbell | |
Author : Shahbaz Chaudhary | |
Contact: shahbazc gmail com | |
License: Do as you wish. Be safe while lifting, plenty of good advice on the internet. | |
''' | |
from itertools import * | |
def calculatePlates(plates=[2.5, 5, 5, 10, 25, 35, 45], isDeadlift=False): | |
''' | |
For an optionally given set of plates, generates a list of weights, | |
the plates required for that weight and warmup sets | |
If list is deadlift, starting point is set to bar + 45 plates | |
''' | |
bar = 45 | |
workSets = 4 | |
startingWeight = bar | |
if isDeadlift: startingWeight = bar + 45 * 2 | |
loadLU = {} | |
#for each element in powerset of plates... (for r in .. for comb in ...) | |
for r in range(len(plates)+1): | |
for comb in combinations(plates,r): | |
load = list(comb) | |
#add up all the plates and the bar | |
weight = sum(load) * 2. + bar | |
if isDeadlift and weight < startingWeight: continue | |
#calculate the incremental weight to add with each warmup set | |
interval = (weight-startingWeight)/workSets or 1 | |
#calculate warmup weights (limit to 4), round down each weight to nearest 5 | |
intervalRange = [x-(x%5) for x in range(int(startingWeight),int(weight),int(interval))][:4] | |
#may be multiple combinations which add up to this weight | |
#this method prefers the fewest plates, also seems to load to fewest plate changes | |
if weight not in loadLU or len(loadLU[weight]['workPlates']) > len(load): | |
loadLU[weight] = {'weight':int(weight), 'workPlates':load[::-1], 'warmupWeights':intervalRange} | |
return loadLU | |
def planWorkout(targetWeight, plates=None, isDeadlift=False): | |
''' | |
For a given target weight, calculate warmup sets and plate configurations for the whole workout | |
''' | |
loadLU = {} | |
if plates is None: loadLU = calculatePlates(isDeadlift=isDeadlift) | |
else: loadLU = calculatePlates(plates=plates, isDeadlift=isDeadlift) | |
setLU = {} | |
setLU[targetWeight] = loadLU[targetWeight]['workPlates'] | |
for warmupWeight in loadLU[targetWeight]['warmupWeights']: | |
setLU[warmupWeight] = loadLU[warmupWeight]['workPlates'] | |
return [{'weight':key, 'plates':setLU[key]} for key in sorted(setLU.keys())] | |
warmupReps = ['2x5 ', '1x5 ', '1x3 ', '1x2 '] | |
for load in sorted(calculatePlates(isDeadlift=False).values()): | |
print load['weight'],'\t', zip(warmupReps,load['warmupWeights']),'\t', load['workPlates'] | |
for reps,load in zip(warmupReps,planWorkout(300)): | |
print reps,load['weight'], load['plates'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result of running this file: