What's a good algorithm for reducing Transaction fees? I'm attempting to use the createrawtransaction to manually create my transactions and I want to (obviously) reduce my fees. The complication I'm having is that I want to send ALL of the bitcoins in my wallet to 2 parties. So I know that I can specify the inputs and outputs, but there's that pesky fee concept which makes it difficult to just spend it all.

So if I have 5 inputs and 2 outputs, how would I go about calculating exactly what the fee will be and reducing it?
https://en.bitcoin.it/wiki/Transaction_fees
Those are rules about calculating fees.

Considering algorithms, i think you should check all possiblities (brute-force) or it could be also some kind of knapsack problem.