Hi all,
I need to have one or two formulas, which gives me the cheapest composition of multiple sizes.
Lets say for a party I need a minimum of 18l of beer. The beer kegs are available only in 1l for $3, 2.5l for $7, 5l for $13 , 20l for $50 sizes and prices.
Now I need to calculate, what is the cheapest composition of kegs:
1x 20l = $50
or 3x5l + 2.5l + 1l = $49 (which would achieve my minimum target of 18l at the lowest cost)
Once I change my required beer to 22l, it would return $56 (20l + 2x1l).
Note: I do not necessarily need to know what keg size and qty of each I need to buy. Just the final $ I have to invest to achieve my target.)
I know I could do it with a list of increment of .5 l and calculate it, but hopefully there is a better formula solution.
PS: Yes, I know the more beer, the better, but that's the task I was given to solve
I need to have one or two formulas, which gives me the cheapest composition of multiple sizes.
Lets say for a party I need a minimum of 18l of beer. The beer kegs are available only in 1l for $3, 2.5l for $7, 5l for $13 , 20l for $50 sizes and prices.
Now I need to calculate, what is the cheapest composition of kegs:
1x 20l = $50
or 3x5l + 2.5l + 1l = $49 (which would achieve my minimum target of 18l at the lowest cost)
Once I change my required beer to 22l, it would return $56 (20l + 2x1l).
Note: I do not necessarily need to know what keg size and qty of each I need to buy. Just the final $ I have to invest to achieve my target.)
I know I could do it with a list of increment of .5 l and calculate it, but hopefully there is a better formula solution.
PS: Yes, I know the more beer, the better, but that's the task I was given to solve