Chapter 6: Problem 18
It is a well-researched fact that men in a rest room generally prefer to maximize their distance from already occupied stalls, by occupying the middle of the longest sequence of unoccupied places. For example, consider the situation where ten stalls are empty. The first visitor will occupy a middle position: The next visitor will be in the middle of the empty area at the left. $$ \text { - } x \text { - } x \text { - - - } $$ Write a program that reads the number of stalls and then prints out diagrams in the format given above when the stalls become flled, one at a time. Hint Use a list of Boolean values to indicate whether a stall is occupied.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.