def get_adjacent_seats(i: int, j: int, seat_arr: list, rule: int) -> list:
    """Get all seats adjacent to the current seat

    :param i: Row number of the current seat
    :param j: Column number of the current seat
    :param seat_arr: Current seating arrangement
    :param rule: 1 or 2 -- Use the part 1 or part 2 rule to update seats
    :return: Next seating arrangement
    """
    adjacent_seats = []
    for k1 in range(-1, 2):
        for k2 in range(-1, 2):
            if k1 == k2 == 0:
                continue
            factor = 1
            while True:
                if i + k1 * factor < 0 or j + k2 * factor < 0:
                    break
                try:
                    seat_to_add = seat_arr[i + k1 * factor][j + k2 * factor]
                except IndexError:
                    break
                if rule == 1:
                    adjacent_seats.append(seat_to_add)
                    break
                elif rule == 2:
                    factor += 1
                    if seat_to_add != '.':
                        adjacent_seats.append(seat_to_add)
                        break
    return adjacent_seats