Title text: General solutions get you a 50% tip.
Another entry in the “My Hobby” series of cartoons. Cueball is embedding NP-complete problems in restaurant orders. Specifically, he is ordering appetizers not by explicitly stating the names, but by the total price of them all. This is a simplified example of the knapsack problem. This is a problem in combinatorial optimization, as follows: If you have a knapsack (backpack or rucksack) which can hold a specific amount of weight, and you have a set of items, each with its own assigned value and weight, you have to select items to put into the knapsack so that the weight does not exceed the capacity of the knapsack and the combined value of all the items is maximized.
In computational complexity theory, NP stands for “nondeterministic polynomial time,” which means that problems which are NP take polynomial running time (i.e. the time a CPU would take to run the program would be polynomial in the input size) to verify a solution, but it is unknown whether finding any or all solutions can be done in polynomial time. Polynomial time is considered efficient; exponential and higher times are considered unfeasible for computation. NP-complete problems are ones which, if a polynomial time algorithm is found for any of them, then all NP problems have polynomial time solutions. In short, particular guesses in NP-complete problems can be checked easily, but systematically finding solutions is far more difficult.
The waiter's problem is NP-complete, since a given order's price can be found and checked quickly, but finding an order to match a price is much harder. (Formal proofs of the NP-completeness of the knapsack problem can be found at the above link.) The most straightforward way for a human to find a solution is to methodically start by first listing all the (6) ways of choosing one appetizer, and their total costs, then list all the (21) ways of choosing two appetizers (allowing repeats), and then list all the (56) ways of choosing three appetizers, and so forth. As any combination of eight appetizers would be more than $15.05, the process need not extend beyond listing all the (1715) ways of choosing seven appetizers.
The title text refers to the fact that NP-complete problems have no known polynomial time general solutions. If the waiter can find an efficient general solution to this he will have solved one of the most famous problems in mathematics. This problem is one of the six remaining unsolved Millennium Prize Problems stated by the Clay Mathematics Institute in 2000, for which a correct solution is worth US$1,000,000. A 50% tip is slightly less than fair.
- The Solution
There are exactly two solutions to the problem posed in the comic strip, combinations of appetizers which total $15.05:
- Seven mixed fruit orders
- A combination of two orders of hot wings, one order of mixed fruit, and one sampler plate
- My Hobby:
- Embedding NP-Complete problems in restaurant orders
- [A menu is shown.]
- Chotchkies Restaurant
- Mixed Fruit 2.15
- French Fries 2.75
- Side Salad 3.35
- Hot Wings 3.55
- Mozzarella Sticks 4.20
- Sampler Plate 5.80
- [Three people sit at a table, including Cueball who is ordering from a waiter.]
- Cueball: We'd like exactly $15.05 worth of appetizers, please.
- Waiter: ...Exactly? Uhh...
- Cueball: Here, these papers on the knapsack problem might help you out.
- Waiter: Listen, I have six other tables to get to-
- Cueball: -As fast as possible, of course. Want something on traveling salesman?
- A film reference is embedded in the menu in the first panel: The restaurant is called “Chotchkies”, a fictional restaurant featured in the film Office Space. In that film, the character Joanna, played by Jennifer Aniston, quits her job at Chotchkies, a typical family-oriented chain restaurant, over their policy that she wear a large number of tchotchkes, or “flair” items – tacky pins, buttons, or other adornments to a worker’s uniform which can often be seen on waiters and waitresses at chain family restaurants, as well as those who work at movie theaters or large retail chain stores.