Skip to content

Instantly share code, notes, and snippets.

@falconair
Created May 31, 2014 02:36
Show Gist options
  • Save falconair/9645dda18e9fecd58a84 to your computer and use it in GitHub Desktop.
Save falconair/9645dda18e9fecd58a84 to your computer and use it in GitHub Desktop.
'''
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']
@falconair
Copy link
Author

Result of running this file:

45  []  []
50  [('2x5 ', 45), ('1x5 ', 45), ('1x3 ', 45), ('1x2 ', 45)]    [2.5]
55  [('2x5 ', 45), ('1x5 ', 45), ('1x3 ', 45), ('1x2 ', 50)]    [5]
60  [('2x5 ', 45), ('1x5 ', 45), ('1x3 ', 50), ('1x2 ', 50)]    [5, 2.5]
65  [('2x5 ', 45), ('1x5 ', 50), ('1x3 ', 55), ('1x2 ', 60)]    [10]
70  [('2x5 ', 45), ('1x5 ', 50), ('1x3 ', 55), ('1x2 ', 60)]    [10, 2.5]
75  [('2x5 ', 45), ('1x5 ', 50), ('1x3 ', 55), ('1x2 ', 65)]    [10, 5]
80  [('2x5 ', 45), ('1x5 ', 50), ('1x3 ', 60), ('1x2 ', 65)]    [10, 5, 2.5]
85  [('2x5 ', 45), ('1x5 ', 55), ('1x3 ', 65), ('1x2 ', 75)]    [10, 5, 5]
90  [('2x5 ', 45), ('1x5 ', 55), ('1x3 ', 65), ('1x2 ', 75)]    [10, 5, 5, 2.5]
95  [('2x5 ', 45), ('1x5 ', 55), ('1x3 ', 65), ('1x2 ', 80)]    [25]
100     [('2x5 ', 45), ('1x5 ', 55), ('1x3 ', 70), ('1x2 ', 80)]    [25, 2.5]
105     [('2x5 ', 45), ('1x5 ', 60), ('1x3 ', 75), ('1x2 ', 90)]    [25, 5]
110     [('2x5 ', 45), ('1x5 ', 60), ('1x3 ', 75), ('1x2 ', 90)]    [25, 5, 2.5]
115     [('2x5 ', 45), ('1x5 ', 60), ('1x3 ', 75), ('1x2 ', 95)]    [35]
120     [('2x5 ', 45), ('1x5 ', 60), ('1x3 ', 80), ('1x2 ', 95)]    [35, 2.5]
125     [('2x5 ', 45), ('1x5 ', 65), ('1x3 ', 85), ('1x2 ', 105)]   [35, 5]
130     [('2x5 ', 45), ('1x5 ', 65), ('1x3 ', 85), ('1x2 ', 105)]   [35, 5, 2.5]
135     [('2x5 ', 45), ('1x5 ', 65), ('1x3 ', 85), ('1x2 ', 110)]   [45]
140     [('2x5 ', 45), ('1x5 ', 65), ('1x3 ', 90), ('1x2 ', 110)]   [45, 2.5]
145     [('2x5 ', 45), ('1x5 ', 70), ('1x3 ', 95), ('1x2 ', 120)]   [45, 5]
150     [('2x5 ', 45), ('1x5 ', 70), ('1x3 ', 95), ('1x2 ', 120)]   [45, 5, 2.5]
155     [('2x5 ', 45), ('1x5 ', 70), ('1x3 ', 95), ('1x2 ', 125)]   [45, 10]
160     [('2x5 ', 45), ('1x5 ', 70), ('1x3 ', 100), ('1x2 ', 125)]  [45, 10, 2.5]
165     [('2x5 ', 45), ('1x5 ', 75), ('1x3 ', 105), ('1x2 ', 135)]  [35, 25]
170     [('2x5 ', 45), ('1x5 ', 75), ('1x3 ', 105), ('1x2 ', 135)]  [35, 25, 2.5]
175     [('2x5 ', 45), ('1x5 ', 75), ('1x3 ', 105), ('1x2 ', 140)]  [35, 25, 5]
180     [('2x5 ', 45), ('1x5 ', 75), ('1x3 ', 110), ('1x2 ', 140)]  [35, 25, 5, 2.5]
185     [('2x5 ', 45), ('1x5 ', 80), ('1x3 ', 115), ('1x2 ', 150)]  [45, 25]
190     [('2x5 ', 45), ('1x5 ', 80), ('1x3 ', 115), ('1x2 ', 150)]  [45, 25, 2.5]
195     [('2x5 ', 45), ('1x5 ', 80), ('1x3 ', 115), ('1x2 ', 155)]  [45, 25, 5]
200     [('2x5 ', 45), ('1x5 ', 80), ('1x3 ', 120), ('1x2 ', 155)]  [45, 25, 5, 2.5]
205     [('2x5 ', 45), ('1x5 ', 85), ('1x3 ', 125), ('1x2 ', 165)]  [45, 35]
210     [('2x5 ', 45), ('1x5 ', 85), ('1x3 ', 125), ('1x2 ', 165)]  [45, 35, 2.5]
215     [('2x5 ', 45), ('1x5 ', 85), ('1x3 ', 125), ('1x2 ', 170)]  [45, 35, 5]
220     [('2x5 ', 45), ('1x5 ', 85), ('1x3 ', 130), ('1x2 ', 170)]  [45, 35, 5, 2.5]
225     [('2x5 ', 45), ('1x5 ', 90), ('1x3 ', 135), ('1x2 ', 180)]  [45, 35, 10]
230     [('2x5 ', 45), ('1x5 ', 90), ('1x3 ', 135), ('1x2 ', 180)]  [45, 35, 10, 2.5]
235     [('2x5 ', 45), ('1x5 ', 90), ('1x3 ', 135), ('1x2 ', 185)]  [45, 35, 10, 5]
240     [('2x5 ', 45), ('1x5 ', 90), ('1x3 ', 140), ('1x2 ', 185)]  [45, 35, 10, 5, 2.5]
245     [('2x5 ', 45), ('1x5 ', 95), ('1x3 ', 145), ('1x2 ', 195)]  [45, 35, 10, 5, 5]
250     [('2x5 ', 45), ('1x5 ', 95), ('1x3 ', 145), ('1x2 ', 195)]  [45, 35, 10, 5, 5, 2.5]
255     [('2x5 ', 45), ('1x5 ', 95), ('1x3 ', 145), ('1x2 ', 200)]  [45, 35, 25]
260     [('2x5 ', 45), ('1x5 ', 95), ('1x3 ', 150), ('1x2 ', 200)]  [45, 35, 25, 2.5]
265     [('2x5 ', 45), ('1x5 ', 100), ('1x3 ', 155), ('1x2 ', 210)]     [45, 35, 25, 5]
270     [('2x5 ', 45), ('1x5 ', 100), ('1x3 ', 155), ('1x2 ', 210)]     [45, 35, 25, 5, 2.5]
275     [('2x5 ', 45), ('1x5 ', 100), ('1x3 ', 155), ('1x2 ', 215)]     [45, 35, 25, 10]
280     [('2x5 ', 45), ('1x5 ', 100), ('1x3 ', 160), ('1x2 ', 215)]     [45, 35, 25, 10, 2.5]
285     [('2x5 ', 45), ('1x5 ', 105), ('1x3 ', 165), ('1x2 ', 225)]     [45, 35, 25, 10, 5]
290     [('2x5 ', 45), ('1x5 ', 105), ('1x3 ', 165), ('1x2 ', 225)]     [45, 35, 25, 10, 5, 2.5]
295     [('2x5 ', 45), ('1x5 ', 105), ('1x3 ', 165), ('1x2 ', 230)]     [45, 35, 25, 10, 5, 5]
300     [('2x5 ', 45), ('1x5 ', 105), ('1x3 ', 170), ('1x2 ', 230)]     [45, 35, 25, 10, 5, 5, 2.5]


2x5  45 []
1x5  105 [25, 5]
1x3  170 [35, 25, 2.5]
1x2  230 [45, 35, 10, 2.5]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment