I'm not sure this is the right place to ask, but here goes anyway.
Background, if you're interested
I've written some pretty fast C code that can accept an ordered list of loans (with current balances, terms, and rates) and will calculate minimum payments for me. Not only this, but it will also calculate an amortization table that
- can accept an extra monthly payment to principle and
- will snowball the minimum payments of paid-off loans into that extra monthly payment.
I'm now challenged with the task of ordering the loans correctly. Going through every possible combination would take O(nn) time (that is, if I have 20 loans, there are 2020 permutations that I have to check if I wanted to check them all). If you want a chuckle, it would take about six times the age of the universe to do it this way.
Clearly, this is not a viable option. I attempted to use the debt-snowball / debt-avalanche methods to determine ordering, but these also appear to not always give the best orderings.
At the moment, I've no better approach than running many thousands (recently ≈25000) of random trials and seeing which loan-orders give the best results (i.e., take the least amount of time total to pay off).
Is there a good way to determine which loan would be most advantageous to pay off first in terms of months spent paying them off?
For each loan, I've only got the current balance, the interest rate, and the term of the loan (and thus the minimum payment). For the entire loan collection, I have a single extra payment to principle that I'll apply to one loan at a time (letting it snowball). Can I derive an optimal payoff-order of the loans from this information? Is there some other information I could derive and then use? (Is paying off one loan at a time even the best approach?)