jewel = [(10, 100), (15, 200), (20, 150)]
weight = 25
jewel.sort(key=lambda x: x[1] / x[0], reverse=True)
total_weight = 0
total_value = 0
for w, v in jewel:
if total_weight + w <= weight:
total_weight += w
total_value += v
print(total_value)
To embed this project on your website, copy the following code and paste it into your website's HTML: