-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path531.py
executable file
·180 lines (128 loc) · 4.74 KB
/
531.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env python3
import configparser
from collections import OrderedDict
from itertools import chain
COLUMN_WIDTH = 12
# Each tuple represents one week
# Each inner tuple represents one set
# The two items in each tuple are "percent weight of working max"
# and "number of reps"
def five_three_one():
return (
((0.65, 5), (0.75, 5), (0.85, 5)),
((0.70, 3), (0.80, 3), (0.90, 3)),
((0.75, 5), (0.85, 3), (0.95, 1)),
((0.40, 5), (0.50, 5), (0.60, 5))
)
def coffinworm():
return (
((0.70, 5), (0.80, 5), (0.90, 5), (0.80, 5), (0.90, 5), (1.0, 3)),
((0.70, 5), (0.80, 5), (0.90, 5), (0.80, 5), (0.90, 5), (1.0, 3)),
((0.65, 5), (0.75, 5), (0.85, 5), (0.85, 5), (0.85, 5))
)
def coffinworm_supp():
return (
((0.70, 5), (0.70, 5), (0.70, 5), (0.70, 5)),
((0.70, 5), (0.70, 5), (0.70, 5), (0.70, 5)),
((0.00, 5), (0.00, 5), (0.00, 5), (0.00, 5))
)
def accessory():
return (
((0.50, 10), (0.60, 10), (0.70, 10)),
((0.60, 8), (0.70, 8), (0.80, 6)),
((0.65, 5), (0.75, 5), (0.85, 5)),
((0.40, 5), (0.50, 5), (0.60, 5))
)
def boring_but_big():
return [[(0.60, 10) for i in range(5)] for i in range(4)]
def first_set_last():
return [[(i, 5) for k in range(5)] for i in (0.65, 0.70, 0.75, 0.40)]
def prep_fat_loss():
sets = (
[(0.70, 5), (0.80, 5), (0.90, 5)],
[(0.65, 5), (0.75, 5), (0.85, 5)],
[(0.75, 5), (0.85, 5), (0.95, 5)],
)
return [l + [(l[0][0], 5) for i in range(5)] for l in sets]
def training_max_test():
return [((0.70, 5), (0.80, 5), (0.90, 5), (1.00, 5))]
p_cache = {}
def get_program(p):
if p not in p_cache:
p_cache[p] = globals()[p]()
return p_cache[p]
def separator(column_cnt):
return "+%s+" % "+".join("-" * COLUMN_WIDTH for i in range(column_cnt))
def format_row(data):
return "|%s|" % "|".join(k.center(COLUMN_WIDTH) for k in data)
def round_weight(w):
remainder = w % 2.5
if remainder < 1.25:
return w - remainder
else:
return w + (2.5 - remainder)
def fill_out_lifts(lifts):
"""Add empty sets to the end of a lift to make set length equal"""
mx_len = max(len(l) for l in lifts)
for lift in lifts:
lift.extend("" for _ in range(mx_len - len(lift)))
def format_set(weight, reps):
# print(weight)
final_weight = max([round_weight(weight), 45.0])
# print(final_weight)
return "%s x %s" % (str("%.1f" % final_weight).rjust(5), str(reps).rjust(2))
def parse_config():
config = configparser.ConfigParser()
config.read("lifts.ini")
lifts = OrderedDict()
for lift in (l.strip() for l in config["lifts"]):
programs = [l.strip() for l in config["lifts"][lift].split(",")]
lifts[lift] = programs
maxes = {lift: float(config["maxes"][lift].strip()) for lift in config["maxes"]}
training_max_pcts = {lift: float(config["training_max_pct"][lift].strip())
for lift in config["training_max_pct"]}
default_max_pct = training_max_pcts.get("default", 0.9)
training_maxes = {}
for lift, mx in maxes.items():
training_maxes[lift] = mx * training_max_pcts.get(lift, default_max_pct)
return lifts, maxes, training_maxes
def print_week(table, week):
SEP = separator(len(table[0]))
print(("Week %d" % (week + 1)).center(len(SEP)))
print(SEP)
print(format_row(i.upper() for i in table[0]))
print(SEP)
for row in table[1:]:
print(format_row(row))
print(SEP)
print()
def print_plan(lifts, maxes):
programs = set(chain.from_iterable(lifts.values()))
week_cnt = max(len(get_program(p)) for p in programs)
for week in range(week_cnt):
table = []
table.append(lifts)
lifts_sets = []
for lift, programs in lifts.items():
lift_mx = maxes[lift]
lift_sets = []
for program in (get_program(p)[week] for p in programs):
lift_sets.extend(format_set(lift_mx * pct, rep) for pct, rep in program)
lifts_sets.append(lift_sets)
fill_out_lifts(lifts_sets)
for row in zip(*lifts_sets):
table.append(row)
print_week(table, week)
def print_maxes(maxes, training_maxes):
print("Current lift maxes")
lift_col_size = max(len(l) for l in maxes)
for lift, mx in maxes.items():
trng_mx = training_maxes[lift]
trng_pct = trng_mx / mx
print("%s %s @ %.2f%%" % (lift.ljust(lift_col_size),
str(round_weight(mx)).zfill(5),
trng_pct))
if __name__ == "__main__":
lifts, maxes, training_maxes = parse_config()
print_plan(lifts, training_maxes)
print_maxes(maxes, training_maxes)