Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Treasures by David_Jones
def treasures(info, limit):
limit *= 1000
c = {}
for treasure, item in sorted(info.items(),
key=lambda x: x[1]['weight'] / x[1]['price']):
amount = int(min(item['amount'], limit // item['weight']))
c[treasure] = amount
limit -= amount * item['weight']
return [f'{treasure}: {c[treasure]}' for treasure in ('golden coin',
'silver coin',
'ruby')
if c[treasure]]
May 7, 2019