Click here to Skip to main content
15,946,699 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
A Company is having a number is cyber cafe. Many customer visit cyber cafe and number if computers are limited. If customer don't find available computer then he leave. You have given a function with 2 arguments : 1 number of computers, 1 : a string with pairs. 1st occurrence of alphabet indicate start of customer and second occurrence indicate end. Only 1 person can use a computer at a time. Return count of customers who left cafe without using computer so that company can improve process.
example :
process(1, ABAB) : should return 1 as only 1 computer is there that is occupied by A when B comes.
process(2,ABACBCDD) : should return 0 as all customer A,B,C, D are able to use Cafe.
process(3, ABCDCDEFEFA) : should return 2 as D and F could use computer.

What I have tried:

I tried processing it from left to right keeping track of number of computer and customer but unable to crack it
Updated 16-Nov-18 8:19am
ZurdoDev 16-Nov-18 13:18pm    
It is very rude to post your home work and not even ask a clear question. Click on the Improve question link and show us the code you have and explain where you are stuck.

Don't just post the assignment and ask someone to do it for you.
Patrice T 16-Nov-18 14:03pm    
Show your work with your results for samples.

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think! Start by trying to do it with a paper and pencil, and work out the processes you need to go through. Then write down those processes and finally try them as written down. If that works, it should be fairly obvious how to translate them to computer code.

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Share this answer
Examples are wrong:
process(1, ABAB): result should be 0 because B have waited until A leave and was able to use a computer.
process(3, ABCDCDEFEFA): result should be 0 because same reason gives same result.

You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900