Thread: complex problem

  1. #1
    Registered User
    Join Date
    Jan 2020
    Posts
    20

    complex problem

    Hi,

    How to write program for below problem:-

    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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I'm not letting this forum become a haven for codechef wannabies dumping their assignments with ZERO EFFORT.

    Sure, post your question AND your attempt in a new thread if you're serious about learning.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with complex numbers
    By dsc in forum C Programming
    Replies: 2
    Last Post: 12-12-2006, 01:18 PM
  2. how complex can you do?
    By wart101 in forum C++ Programming
    Replies: 10
    Last Post: 10-05-2005, 11:50 AM
  3. Help with Complex Quadratic Problem
    By Megaten in forum C++ Programming
    Replies: 2
    Last Post: 09-21-2005, 05:54 PM
  4. Another more complex problem,
    By Tynnhammar in forum C++ Programming
    Replies: 9
    Last Post: 09-29-2004, 11:35 PM
  5. more complex C++
    By EvBladeRunnervE in forum C++ Programming
    Replies: 2
    Last Post: 02-17-2003, 06:07 PM

Tags for this Thread