menu_orderer.py 1.88 KB
from pprint import pprint
from typing import List, Tuple

from z3 import *


def find_all_orders(menu_items: List[Tuple[str, int]],
                    goal_price: int) -> List[List[Tuple[str, int]]]:
    """Find all orders that cost exactly the goal price, given the menu.

    Inspired by https://xkcd.com/287/.

    Args:
        menu_items (List[Tuple[str, int]]): A list of all menu items and their
            prices. Assume that all prices are positive.
        goal_price (int): Desired exact amount to spend.

    Returns:
        List[List[Tuple[str, int]]]: A list of all orders that cost exactly the
            goal price. Items not ordered are present with amount 0.
    """
    pass
    # TODO: Implement me!


if __name__ == '__main__':
    pass
    # You can uncomment the below test cases to try out your implementation,
    # or add your own scenarios.

    # xkcd_menu = [
    #     ('mixed_fruit', 215),
    #     ('french_fries', 275),
    #     ('side_salad', 335),
    #     ('hot_wings', 355),
    #     ('mozz_sticks', 420),
    #     ('sampler_plate', 580),
    # ]
    # goal_price = 1505
    # pprint(find_all_orders(xkcd_menu, goal_price))

    # red_door_menu = [
    #     ('avocado_toast', 625),
    #     ('blue_salad', 725),
    #     ('chicken_sandwich', 750),
    #     ('coffee', 230),
    #     ('mocha', 460),
    #     ('latte', 400),
    #     ('hot_chocolate', 300),
    #     ('chai', 350),
    #     ('cold_coffee', 500),
    #     ('brain_freeze', 525)
    # ]
    # goal_price = 1315
    # pprint(find_all_orders(red_door_menu, goal_price))

    # chouse_menu = [
    #     ('quesadilla', 100),
    #     ('chicken_nuggets', 300),
    #     ('burger', 400),
    #     ('boba', 150),
    #     ('tofu_nuggets', 150),
    #     ('fries', 150),
    #     ('special', 500),
    #     ('soda', 100),
    # ]
    # goal_price = 1025
    # pprint(find_all_orders(chouse_menu, goal_price))