Пример #1
0
    def generate(self, round_num: int) -> Dict[int, List[Person]]:
        """Return the new arrivals for the simulation at the given round.

        The returned dictionary maps floor number to the people who
        arrived starting at that floor.

        You can choose whether to include floors where no people arrived.
        """
        person_dict = {}
        for floor in range(1, self.max_floor + 1):
            person_dict[floor] = []
        for person in range(self.num_people):
            person = Person(
                random.sample(range(1, self.max_floor + 1), 1)[0],
                random.sample(range(1, self.max_floor + 1), 1)[0])
            while person.start == person.target:
                person.target = \
                    random.sample(range(1, self.max_floor + 1), 1)[0]
            person_dict[person.start].append(person)
        return person_dict