box = [70, 50, 80, 50]
L = 100

box.sort()

light = 0
heavy = len(box) - 1
boat = 0

while light <= heavy:
    if box[light] + box[heavy] <= L:
        light += 1
        heavy -= 1
    else:
        heavy -= 1
    boat += 1

print(boat)

Embed on website

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