Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fast food restaurants often offer customers the option of ordering a set of items that constitute a meal. For instance, if a person buys a

Fast food restaurants often offer customers the option of ordering a set of items that constitute a meal. For instance, if a person buys a hamburger, fries and a soft drink at the same time, the restaurant might offer the items at a discount. Imagine a strange fast food restaurant that offers these items for sale: dumplings, hamburgers, ramen, salads, cups of soda and bottles of water. These items are represented using the following strings: dumplings: dumpling hamburgers: hamburger ramen: ramen salads: salad cups of soda: soda bottles of water: water Discounts are offered to patrons who order one or more of these combinations: Asian Fusion: a dumpling and ramen The Heart Attack: a hamburger and a soda The Unhappy Meal: a salad and a bottle of water Write the function find combos(orders), which takes a list of strings called orders as its argument. The strings are chosen from the set of six strings given above and represent a collection of items that a patron wants to purchase at the restaurant. (You may assume that only valid strings appear inside orders.) The function counts the number of meal combinations it can make from the list of strings given. For instance, if the orders list were [water, soda, water, soda, salad, ramen, water, dumpling, salad, dumpling], the function would detect one Asian Fusion meal, zero Heart Attack meals, and two Unhappy Meals. The function would return the list [1, 0, 2] as a result. Note that the counts are returned in this order inside the returned list: [# of Asian Fusions, # of Heart Attacks, # of Unhappy Meals] For this part of the assignment you do not need to use while-loops. Simply use a for-loop to traverse over the list of strings. However, you probably will want to use Boolean operators to help you detect the meal combinations. image text in transcribed

Examples: [2, 0, 0] find.combos (['dumpling', 'water', 'dumpling', 'dumpling', ramen, 'ramenwater' ]) find.combos ([' soda,dumpling', ' hamburger, 'hamburger hamburger, water', 'dumpling', 'ramen']) find.combos ([' salad, 'soda', dumpling', hamburger, water' water, soda, 'ramen, salad') find.combos (['water,water soda', 'soda',salad', 'dumpling",soda', 'dumpling']) find.combos (['water, 'soda''water, 'salad', soda', hamburger,soda',hamburger,'soda, 'salad,soda']) find.combos (['hamburger water,ramen', salad',water, 'soda, 'soda, soda ramen', salad, 'ramen, 'ramen, 9 , 1, 1, 2] [0, 2, 2] amen find.combos ([' water, 'soda', 'hamburger', soda', 'dumpling', ramen', dumpling', ' "soda, 'salad, 'salad','dumpling']) find.combos (['water, ramen, 'dumpling,ramen',salad dumpling','ramen', 'soda''ramen, 'dumpling') find.combos ([' salad', ramen salad, 'ramen', 'soda' water', find.combos ([' ramen 'water,ramen, 'soda ramen', hamburger,soda', ramen'dumpling','hamburger]) hamburger, 'soda soda, salad', salad,ramen'])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions