def changegreedy(coins,amount):
    result = [0] * len(coins)

    for i in xrange(len(coins)-1,-1,-1):
        # #coins[i] used = amount/coins[i]
        # amount = remainder, or amount - (amount//coins[i]) * coins[i]
        result[i],amount = divmod(amount,coins[i])

    return result

def greddyItter(coins,amount):
    result = [0] * len(coins)

    for i in xrange(len(coins)-1,-1,-1):

        while coins[i] <= amount:
            amount -= coins[i]
            result[i]+=1

    return result

if __name__ == '__main__':
    import testharness
    testharness.runTests(changegreedy)

def changeslow(coins,amount):
    result = [0] * len(coins)

    coinsUsed = slowhelper(coins,amount)

    #turn returned array of coin values used into 
    for i in coinsUsed:
        result[i]+=1

    return result

if __name__ == '__main__':
    import testharness
    testharness.runTests(changeslow)




#################################################
#####   too slow version   ######################
#################################################
# from operator import add
# def changeslow(coins,amount):
#     result = [0] * len(coins)

#     #base case
#     for i in range(len(coins)):
#         if coins[i] == amount:
#             #print "returned coin: " + str(coins[i])