Consider this situation: an office with 100 employees and two restrooms.
Taken literally, it is not possible for the office described to function if we assume that each employee visits the loo once per day, and the average time per visit is >= 10 minutes. This is easily proved with simple arithmetic. (8 hour workday*60 minutes per hour = 480 minutes per workday, 10 minutes per visit * 100 employees/2 johns = 500 minutes per crapper required)
However, it should be evident that since calls of nature cannot be scheduled to the convenience of the workplace, the actual breakdown point comes at a much lower average time per visit, still assuming one visit per employee per day.
In this challenge, your task is to to simulate this unfortunate workplace, and similar situations. Since this is an effectively bottomless problem, we're not giving you a specification, but here are some ideas you might consider:
- Basic: Model the situation as described in the post: 100 employees in a building with two restrooms. Assume that each visit takes exactly the average time, which for convenience we'll say is ten minutes. Assume visits are random impulses, evenly distributed throughout the day. Assume one visit per employee per day. Assume that toilets are unisex, and that one line serves both toilets.
As output, provide a list of employees and the time each one spent in the queue.*
- Intermediate: Get a little more realistic. "Visits" now vary in length, distributed around the average time in some reasonable fashion. (Does this change make a difference to the result?) The average time per visit can be configured.
Do a little more analysis on the output: assuming everyone leaves the building at 5:00, how long did employees spend in the queue? How many went home with bladders bursting?
- Advanced: More realistic: Toilets are gendered. (implying that employees must be gendered). "Visits" are now variable in length, clustered around two distinct averages, or perhaps four (ie, these times may vary by gender). Visits are now clustered in a more reasonable distribution. (use your imagination: consider lunch times, break times, and ordinary human psychology)
Provide visualizations of your results. Graphs would be cool. Animations of the line would be awesome.
- The obvious data structure for modelling this problem is the queue (the name sorta gives it away, doesn't it?). However, there are other approaches.
- Novice Python programmers who have not explored object-oriented python might find this a convenient opportunity to do so.
If you have questions about the challenge, post them here and Simown or I will come up with some sort of answer.
EDIT: * Having worked the problem, I think this might not be the most useful or interesting output. For the basic challenge, it would be acceptable to simply produce a running report of the state, or to report some interesting statistics. For example, average wait time would be interesting, and also the number of employees who were still in line at the close of business. Further analysis is up to your imagination: part of the challenge here is to figure out what sorts of information you'd like to get from this kind of model.