Last active
August 29, 2015 14:06
-
-
Save beatobongco/1f42e62d51d30403a648 to your computer and use it in GitHub Desktop.
Resistance Band Calculator
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
import itertools | |
#config | |
thepool = [10,20,30,40,60,100] | |
HOWMANY = 5 | |
# get all possible (mynum) piece combinations from a set of (stuff). Can repeat pieces | |
def get_combos(stuff, mynum): | |
returned_list = [] | |
for subset in itertools.combinations_with_replacement(stuff, mynum): | |
returned_list.append(subset) | |
print("Pool results: Got {0} results.".format(len(returned_list))) | |
return returned_list | |
# from a collection of numbers, get ways they can be combined into a 3-slotted handle without repeating themselves | |
def get_3_combos(stuff): | |
returned_list = [] | |
for x in range(1,4): | |
for subset in itertools.combinations(stuff, x): | |
temp = 0 | |
for i in subset: | |
temp = temp + i | |
returned_list.append(temp) | |
a = sorted(list(set(returned_list))) | |
return a | |
ulti = [] | |
for x in get_combos(thepool, HOWMANY): | |
temp=0 | |
score = 0 | |
mylist = get_3_combos(x) | |
for i in mylist: | |
if(i>60): | |
if(i-temp == 10): | |
score=score + 1 | |
else: | |
break | |
temp=i | |
mate = [] | |
mate.append(x) # name of combo | |
mate.append(mylist) # the actual items in combo | |
mate.append(len(mylist)) # the number of combinations it makes | |
mate.append(score) # progressive score | |
ulti.append(mate) | |
print("most combinations followed by biggest weight") | |
ulti.sort(key=lambda x: (x[2],x[1][len(x[1])-1]), reverse=True) | |
for i in range(0,6): | |
print(ulti[i]) | |
print("most combinations followed by most progressive from 60 lbs+, then weight") | |
ulti.sort(key=lambda x: (x[2],x[3],x[1][len(x[1])-1]), reverse=True) | |
for i in range(0,6): | |
print(ulti[i]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment