rosetta code solution to coin count problem