Interleave gains and losses
Given a list of per-trade P and L values (some non-negative, some negative), produce an arrangement that alternates starting with a non-negative value: gain, loss, gain, loss, and so on. Preserve the original relative order within the gains and within the losses. If one side runs out, append the remaining values in order.
pnl = [3, -1, -2, 4, -5, 6]
-> [3, -1, 4, -2, 6, -5]
Return the interleaved list. Aim for .
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.