This entry was posted in Exercise by dgookin. Before then, please try this Exercise on your own. In fact, it could have only one stop going up or down depending on the random requests, though such an occurrence is highly unlikely.Ĭlick here to read my solution. So it's unnecessary to ensure that the elevator always have eight stops. Keep in mind that multiple passengers may get off or arrive at a single stop, going up or going down. Random numbers determine the floor requests both up and down. You can code your solution however you like, but in my solution I use only a single array with 15 elements, one for each floor. Never mind who exits or enters on which floor the program need not be that complex. On the return trip, the elevator visits floors 14, 10, 9, and 5 to collect passengers on the ride down. Here is sample output from my solution, which illustrates one way to solve the puzzle: Floor: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Ībove, passengers on the ride up request stops on the 3rd, 8th, 11th, and 13th floors. Your task is to output a map of the simulation, showing the 15 floors and each stop requested on the way up followed by each stop requested on the way down. They desire to go up from the lobby or return to the lobby from various floors. Assume eight passengers are wanting to ride the elevator, either alone or in groups. Assume a building has 15 floors - like a 15-element array. Rather than burden you with such a complex ordeal, I have a simpler proposal:įor this month’s Exercise your task is to code a simple elevator simulation. He also have a same username in the Skyscraper Simulator Forum. His channel is the largest elevator channel in Israel. He mostly uses public transportation to go film elevators. The elevator’s return trip collects these people, stopping at the given floors on the ride down, ending at the lobby.Ĭreating an elevator simulation would be fun, but a beast if you code all the details (passengers on/off, floors requested). In Aughe filmed some elevators with itzik200 in Bat Yam. Suppose people on floors 14, 10, 9, and 5 have pressed the down button. On the return trip, the elevator collects people requesting to go down. The elevator rises to each floor sequentially. For example, four people walk into the elevator and select floors 3, 8, 11, and 13. On the way up, elevators stop at floors based on user input. Each stop going up represents a passenger’s desired destination, as do stops on the return trip. As I rode the elevator up to my floor, I thought about how the lift worked like a pointer traversing an array: The floors are elements. I recently stayed at a resort with a tall hotel tower, over 30 stories.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |