-
-
Save g-leech/075f47dcf6a66508dbd380b56961b8c8 to your computer and use it in GitHub Desktop.
This file contains 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
budget = 100 | |
names = ["A", "B", "Best", "Pricey"] | |
prices = [100, 10, 1, 101] | |
volumes = [10, 1, 0.1, 100] # litres | |
abvs = [1, 10, 100, 100] # % | |
for i, p in enumerate(prices) : | |
if p > budget: | |
del names[i] | |
del prices[i] | |
del volumes[i] | |
del abvs[i] | |
units = [ v * p for v,p in zip(volumes, abvs) ] | |
bangforbuck = [ u / p for u,p in zip(units, prices)] | |
i = max(zip(bangforbuck, range(len(bangforbuck))))[1] | |
print(names[i]) | |
print("Units per €:", bangforbuck[i], "units") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment