Python Forum
problem with complex scenario
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with complex scenario
#1
Hi,

How to write program for below complex scenario in python 2 language:-

Chef's ingredients:-


1.The chef receives exactly 1 ingredient per day from the market.The
ingredients never repeat.

2. Every ingredient belongs to 1 of the 3 categories namely FIBER,FAT & CARB.

3.Every ingredient has a unique ingredient id.

4.The ingredient id always starts with the category name (ex:FIBERBroccoli,FATCheese,CARBRice)

Chef's Dishes

1. All of the chef's dishes have a constant number of ingredients.(this will be your program's input)

2. All the ingredients used will be fully used in a Dish. The chef doesn' use some part/quntity of an ingredient.

3.All of the chef's dishes mush have at least 60% of the ingredients from a single category.(i.e. if the chef cooks using
4 ingredients,then at leaast 3 FAT ingredients OR at least 3 FIBER ingredients OR at least 3 CARB ingredients are needed)


Chef's Cooking style:-

1. If the chef has multiple options of ingredients for the dish,then he takes the oldest possible ones to cook
in the order of their arrival.

2.After the chef prepares a dish,the ingredients used can Not be reused as theyhave been already used.

3.The chef prepares a maximum of 1 dish per day.

4.if the Chef does not have enough ingredients to cook the dish with above mentioned rules,then he does not
cook on that day.

Given the input array of ingredient id that the chef receives every day (i.e. array index is the day number)
write a program to print when does the chef cook a dish and when he does not.


Input:-

Line 1: The total number of days for the scope of the problem(1<=input<=20)

Line 2: The exact number of ingredients that chef uses to cook(1<=input<=20)

Line 3: The space separated ingredient ids.(6<=length(ingredientid)<=20)

Output:- Print the ":" separated used ingredient ids in order of their arrival if the chef cooks on that day
and print "-" if the chef doesn't cook anything on that day.Print the output as single string.

Example input 1:

5
3
FATOil FATCheese FATEgg FIBERSpinach CARBRice FIBERBeans

Example INPUT 2:

6
3
FATOil:FATCheese FATEgg FIBERSpinach CARBRice FIBERBeans

EXAMPLE OUTPUT 2:

--FATOil:FATCheese:FATEgg--FIBERSpinach:CARBRice:FIBERBeans

EXAMPLE INPUT 3:

12
4
FATOil FIBERSpinach CARBRice FATCheese FIBERBeans FATEgg
FIBERBroccoil CARBPotato CARBCorn FATOlive FIBERCarrot


Thanks
Reply


Messages In This Thread
problem with complex scenario - by jk91 - Jan-29-2020, 09:24 PM
RE: problem with complex scenario - by micseydel - Jan-29-2020, 10:44 PM
RE: problem with complex scenario - by buran - Jan-30-2020, 08:15 AM
RE: problem with complex scenario - by jk91 - Jan-30-2020, 04:48 PM
RE: problem with complex scenario - by jk91 - Feb-05-2020, 07:52 AM
RE: problem with complex scenario - by jk91 - Feb-05-2020, 01:03 PM
RE: problem with complex scenario - by jk91 - Feb-05-2020, 02:03 PM
RE: problem with complex scenario - by jk91 - Feb-05-2020, 03:19 PM
RE: problem with complex scenario - by jefsummers - Feb-05-2020, 04:43 PM
RE: problem with complex scenario - by jk91 - Feb-18-2020, 11:55 AM
RE: problem with complex scenario - by buran - Feb-05-2020, 04:49 PM
RE: problem with complex scenario - by jk91 - Feb-13-2020, 03:16 PM
RE: problem with complex scenario - by jk91 - Feb-13-2020, 06:05 PM
RE: problem with complex scenario - by jk91 - Feb-14-2020, 05:15 PM
RE: problem with complex scenario - by jefsummers - Feb-14-2020, 05:57 PM
RE: problem with complex scenario - by jk91 - Feb-17-2020, 08:17 AM
RE: problem with complex scenario - by buran - Feb-17-2020, 09:24 AM
RE: problem with complex scenario - by jefsummers - Feb-18-2020, 12:25 PM
RE: problem with complex scenario - by jk91 - Feb-18-2020, 01:39 PM
RE: problem with complex scenario - by jk91 - Feb-18-2020, 03:42 PM
RE: problem with complex scenario - by jefsummers - Feb-18-2020, 04:28 PM
RE: problem with complex scenario - by jk91 - Feb-26-2020, 05:57 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020