ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hi user i want write this program with python or c++.but i have some problem.can you help me?
you have a list of different cakes to make,each requering a certain amount of time to bake,you also have exactly 3 ovens to bake the cakes in,and each oven can only bake on cake at time.assuming that the time requered to take a cake out and put another one in is negligble,can you determine that smallest amount of time you will need to spend baking,given the list of cakes to make?
Input:
the input test file will contain multiple cases,with each case on a single line.the line begins with an integer n(where 1<=n<=40),the number of cakes to bake.fllowing are n integer t1,...,tn(where 1<=ti<=30),indicating the time in minutes required to bake each of your cakes.end-of-input is marked by a single line containing 0;do not process this line.for example
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
Above is our standard homework response......
The key point is that you have not shown us what work you have done. You also say that you "have some problem", but you don't say what it is.......
I can give one easy answer: Since this is obviously just a programming exercise, Python will be much easier.
Since this is obviously just a programming exercise, Python will be much easier.
1) Since the actual programming would be trivial in any programming language you know, the language you know best will be easier. (I could code this in Python, but would find it much easier in C++, Java or even C).
Reading the input is the only part where the choice of language makes even a moderate difference. I expect that if you know Python fairly well (I don't) reading the input should be easier in Python.
2) The algorithm design should be separate work from the coding. There is an obvious "brute force" algorithm, that makes the algorithm design trivial. Up to about 18 cakes the "brute force" algorithm would take so little time to run that you wouldn't have any reason to work hard to design an algorithm that runs faster. But at 40 cakes, I don't think the "brute force" algorithm would be usable.
So start by deciding how good an algorithm you need. Then design the algorithm. Then select a language and write your code.
Per the LQ Rules, please do not post homework assignments verbatim.
Here is the irritating thing; it's not a verbatim post of a homework assignment. Enough care has not been taken for it to be accurate.
If the OP is asking for general advice on the selection of the easiest language for a problem like this, I don't have a problem with that (its Python, if you don't know any of the languages well; if this is a learning excercise, there may be a case for choosing one that you don't currently know, but the easiest is still python, but, in learning, the easiest isn't always the only valid selection). If what is being asked for is anything more like a worked out solution, that would be against the prohibition on just doing people's homework for them.
you have a list of different cakes to make,each requering a certain amount of time to bake,you also have exactly 3 ovens to bake the cakes in,and each oven can only bake on cake at time.assuming that the time requered to take a cake out and put another one in is negligble,can you determine that smallest amount of time you will need to spend baking,given the list of cakes to make?
Input:
the input test file will contain multiple cases,with each case on a single line.the line begins with an integer n(where 1<=n<=40),the number of cakes to bake.fllowing are n integer t1,...,tn(where 1<=ti<=30),indicating the time in minutes required to bake each of your cakes.end-of-input is marked by a single line containing 0;do not process this line.for example
This looks like cut and paste to me---most likely homework, but I suppose there could be another explanation.....
Also note that OP did NOT ask which language to use. (I want to program this.....but I have some problem")
All this aside, we DO give benefit of the doubt. I hope that jokar will post back and clarify his/her intentions and respond to the advice we have already given.
This looks like cut and paste to me---most likely homework, but I suppose there could be another explanation.....
Given the roughly 27 grammar/spelling/formatting errors (many repeated), I was hoping that it wasn't a cut 'n paste, as that would raise other issues.
Quote:
Also note that OP did NOT ask which language to use. (I want to program this.....but I have some problem")
No, I was noting that the OP could have been asking 'which language would be the best choice for this type of problem', which would be legitimate, but didn't make that clear (that's another, and more important, error, if anyone is still counting!).
hi user i want write this program with python or c++.but i have some problem.can you help me?
you have a list of different cakes to make,each requering a certain amount of time to bake,you also have exactly 3 ovens to bake the cakes in,and each oven can only bake on cake at time.assuming that the time requered to take a cake out and put another one in is negligble,can you determine that smallest amount of time you will need to spend baking,given the list of cakes to make?
Input:
the input test file will contain multiple cases,with each case on a single line.the line begins with an integer n(where 1<=n<=40),the number of cakes to bake.fllowing are n integer t1,...,tn(where 1<=ti<=30),indicating the time in minutes required to bake each of your cakes.end-of-input is marked by a single line containing 0;do not process this line.for example
1 30
3 15 10 20
5 6 7 8 9 10
0
output:
30
20
15
My answer to you on this is pretty simple. The problem can be solved in any of the programming languages you specified. Choose one that you're comfortable with and jump right into the world of programming!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.