Click here to download source files.

This video demonstrates how to calculate the minimal number of coins.