jewel = [(10, 100), (15, 200), (20, 150)]
weight = 25

max_value = 0

for i in range(len(jewel)):
    total_w = 0
    total_v = 0
    for j in range(i, len(jewel)):
        total_w += jewel[j][0]
        total_v += jewel[j][1]

        if total_w <= weight:
            max_value = max(max_value, total_v)

print(max_value)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: