Solution to CodeChef practice problem http://www.codechef.com/problems/COINS