title: How can I find the optimal buy and sell points for a stock if I have a transaction cost?
body: <p>If I have a list of prices, say <code>[4,2,5,6,9,3,1,2,5]</code> and I have a transaction cost of $2 and I am able to buy and short sell then the optimal strategy is buy at 2 switch positions at 9 and and switch again at 1. So the optimal buy indices are <code>[1,6]</code> and the optimal sell indices are <code>[4]</code>. How can this be solved programmatically? Specifically I'm looking to be pointed in the right direction (i.e. This is a perfect case for A* ... or whatever) rather than a solution.</p>