Join the ropes
You have ropes of the given lengths and must join them into one. Joining
two ropes costs the sum of their lengths and produces a rope of that
length. Write join_cost(ropes) that returns the minimum total cost of
joining them all. A single rope costs 0.
join_cost([4, 3, 2, 6]) -> 29 (2+3=5, 4+5=9, 6+9=15; 5 + 9 + 15 = 29)
join_cost([5]) -> 0
The point is to practise "repeatedly take the two smallest and put the result back", which is what a heap is for.
def join_cost(ropes):
...