Created
September 19, 2019 13:01
-
-
Save kdeloach/2050c7538000e267a5553d9e1ac18687 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
bar = 45 | |
plates = [55, 45, 35, 25, 10, 10, 5, 5, 2.5] | |
min_weight = int(bar + min(plates) * 2) | |
max_weight = int(bar + sum(plates) * 2) | |
def greedy(goal): | |
goal -= bar | |
goal /= 2 | |
out = [] | |
for plate in plates: | |
if goal <= 0: | |
break | |
if plate > goal: | |
continue | |
goal -= plate | |
out.append(str(plate)) | |
out = ', '.join(out) | |
return out | |
for weight in range(min_weight, max_weight + 1, 5): | |
plates_str = greedy(weight) | |
print(f'{weight}\t{plates_str}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment