Gift Card | How to solve this?
Anonymous User
3265

My food delivery startup wants to give out some gift cards to loyal customers. I want to provide them
with a combination of food to order which adds up exactly to the gift card so they don't have to spend
any additional money. (let's assume that delivery, taxes, etc, are free for our customers)

From the following menu, and list of gift card values, determine what they could order:

The Menu:
'sandwich': 6.85,
'toast': 2.20,
'curry': 7.85,
'egg': 3.20,
'cheese': 1.25,
'coffee': 1.40,
'soup': 3.45,
'soda': 2.05,

The Gift Card Amounts (test cases):
5, 10, 15, 20, 25, 30, 40, 50, 100, 250

Constraints/Hints:
- customers must use 100% of the gift card value
- a customer could order any quantity of any menu item
- there are combinations to be found for every gift card, none of these are trick values

Find the first combination of food that adds up to the gift card amount, print out only one combination
for that gift card, and move on to the next gift card amount.

Example:
the $5 gift card could have one of two combinations:
['coffee', 'coffee', 'toast']
['cheese', 'cheese', 'cheese', 'cheese']
Comments (4)