Solution to the mincoins problem.