Not fast enough for Diamond Dozen?

I am having the trouble on this level where I get most of the coins but at the end there is one that disappears before my hero can get to it, I have speed ring and soft leather boots but I still miss it.

def valueOverDistance(item):
    return item.value / hero.distanceTo(item)

# Return the item with the highest valueOverDistance(item)
def findBestItem(items):
    bestItem = None
    bestValue = 0
    itemsIndex = 0
    # Loop over the items array.
    # Find the item with the highest valueOverDistance()
    while itemsIndex < len(items):
        item = items[itemsIndex]
        if item.value > bestValue:
            bestItem = items[itemsIndex]
            bestValue = bestItem.value
        itemsIndex += 1
    return bestItem

See Diamond Dozen always non optimal

1 Like