Ported CoinSelection. mvn test passed.