Even if your first solution is allowed (and I didn't anticipate flipping between loans when repaying them), it seems that paying off the smaller loan first is still advantageous.
You spend $27,166 total paying off the loans if you pay the $2k loan off first and then the $20k loan.
Using your method you spend $27,204 which is more.
It seems more and more likely that the optimal solution might be just paying off the smaller loan completely first, because compound interest of 5% really adds up after several months. I'm just not sure if any kind of split payment method would be better in terms of interest.
You spend $27,166 total paying off the loans if you pay the $2k loan off first and then the $20k loan.
Using your method you spend $27,204 which is more.
It seems more and more likely that the optimal solution might be just paying off the smaller loan completely first, because compound interest of 5% really adds up after several months. I'm just not sure if any kind of split payment method would be better in terms of interest.