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
#2
Generally speaking when someone posts code asking for homework help (even if it's outside of the homework section, which I'm going to move this to), we want to see their code attempt. Posts like this are often interpreted, rightfully or not, as "do it for me posts." We really need to see some effort from you.

If you're totally unsure of where to start, this is a good place.
Reply
#3
in addition to @micseydel advise - note that python2 support ended as of 01 January this year. Writing python2 code for a code base that is yet to be migrated to python3 is understandable, but still doubtful (you are way past the time to start migrating, no need to write new code in python2, better start migrating old code base). Writing python2 code for homework is non-sense.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
but even in python 3 how can i write such a complex program which should resolve this problem?

also link posted as a good by micseydel is so generic that it can not resolve my problem it is very very tough problem to solve.
Reply
#5
hi,
to solve this problem which python software i should download and install considering I am on Windows 7 platform.

Also please give some hints how to start solving so complex problem step by step.

Thanks
Reply
#6
any updates please :-

the program has to read inputs from standard input
the program has to write the solution to standard output

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/

int main()
{
int numberOfDays;
cin >> numberOfDays; cin.ignore();
int numberOfIngredients;
cin >> numberOfIngredients; cin.ignore();
for (int i = 0; i < numberOfDays; i++) {
string ingredientId;
cin >> ingredientId; cin.ignore();
}
}

for 1st case output should be like :- ---FATOil:FIBERSpinach:FATCheese-
2nd:---FATOil:FATCheese:FATEgg--FIBERSpinach:CARBRice:FIBERBeans
3rd:-12
4
FATOil FIBERSpinach CARBRice FATCheese FIBERBeans FATEgg FIBERBroccoli CARBPotato CARBCorn FATOlive FIBERCarrot CARBBeetroot
4th:-

-----FIBERBroccoli:CARBRice:CARBOat:CARBCorn-FATEgg:FATCoconut:FIBERBeans:FATCheese-----FATSalmon:FIBERCarrot:FIBERSpinach:FIBERPumpkin---CARBQuinoa:CARBPotato:FATOil:CARBWheat

5h :-

18
5
FIBERBroccoli FATEgg FIBERPumpkin FATOil CARBPotato FATSalmon CARBWheat FATCheese FIBERSpinach CARBQuinoa CARBOat FATOlive CARBCorn FIBERCarrot CARBRice FATCoconut FIBERBeans FIBERBarley

how can i install python's latest version which should support windows 7 operating system 32 bit?

thanks
Reply
#7
Hi, is there any one available to answer my queries on this forum please?
Reply
#8
i am getting this error e000: Service Pack 1 is required to continue installation
nd i tried to download it and restarted my system stll same error would it be worth to download 3.8.1 for windows 7 32 bit or should go after pycharm whichone should be better or should i have both for extensive grasp or to become expert in python?
Reply
#9
1. I would install Anaconda. You don't actually have to install anything - you can use colab.research.google.com which is completely online and is Python 3. Your programs are stored in your Google Drive. It uses notebook style, but you can put everything in one cell if that is your preference.
2. Not only is Python 2 no longer supported, neither is Windows 7. Recommend upgrading that as well if at all possible.
3. Take the assignment in pieces. Your example code is not in Python, so we can't see effort in Python. Start by writing the code to input the data.
4. You need to get comfortable with arrays for storing this information. I assume you are in a class and getting instruction in some way. I also like the Socratica series of Youtube videos for learning Python. Matches my sense of humor. Get the basics, then write code to apply them.
Reply
#10
look at https://python-forum.io/Thread-Part-1-Py...er-Windows
pycharm is IDE, i.e. it's not an alternative/replacement for python
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

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