text: import numpy as np
  
  class solve_day(object):
  
      with open('inputs/day11.txt', 'r') as f:
          data = f.readlines()
          data = [d.strip() for d in data]
  
  
      def part1(self):
          grid = []
          
          [grid.append(x) for x in self.data]
  
          rows = len(grid)
          seats = len(grid[0])
  
          def seating():
  
              switch_to_occupied = []
              switch_to_empty = []
  
              for row in range(rows):
                  for seat in range(seats):
  
                      adjacent_seats = []
  
                      for adj_row in range(row-1, row+2):
                          for adj_seat in range(seat-1, seat+2):
                              if adj_row < 0 or adj_seat < 0 or adj_row >= rows or adj_seat >= seats:
                                  continue
                              if adj_row == row and adj_seat == seat:
                                  pass
                              else:
                                  adjacent_seats.append(grid[adj_row][adj_seat])
  
  
                      # check for empty
                      if grid[row][seat] == 'L' and len([x for x in adjacent_seats if x == '#']) == 0:
                          switch_to_occupied.append([row,seat])
  
                      # check for occupied
                      if grid[row][seat] == '#' and len([x for x in adjacent_seats if x == '#']) >= 4:
                          switch_to_empty.append([row,seat])
  
              for seat in switch_to_occupied:
                  grid[seat[0]] = grid[seat[0]][:seat[1]] + '#' + grid[seat[0]][seat[1]+1:]
  
              
              for seat in switch_to_empty:
                  grid[seat[0]] = grid[seat[0]][:seat[1]] + 'L' + grid[seat[0]][seat[1]+1:]
  
              return grid
  
          for i in range(100):
              seating()
  
          c = 0
          for x in grid:
              c += len([y for y in x if y == '#'])
  
          return c
  
  
      def part2(self):
          grid = []
          
          [grid.append(x) for x in self.data]
  
          rows = len(grid)
          seats = len(grid[0])
  
          def seating():
  
              switch_to_occupied = []
              switch_to_empty = []
  
              for row in range(rows):
                  for seat in range(seats):
                      # if row == 0 and seat == 0:
                          # print('testing 0,0')
                          # print(grid[row][seat])
  
                      adjacent_seats = []
  
                      for adj_row in range(row-1, row+2):
                          for adj_seat in range(seat-1, seat+2):
                              if adj_row < 0 or adj_seat < 0 or adj_row >= rows or adj_seat >= seats:
                                  continue
                              if adj_row == row and adj_seat == seat:
                                  pass
                              else:
                                  adjacent_seats.append(grid[adj_row][adj_seat])
  
                              # print(adjacent_seats)
  
  
                      # check for empty
                      if grid[row][seat] == 'L' and len([x for x in adjacent_seats if x == '#']) == 0:
                          # grid[row] = grid[row][:seat] + '#' + grid[row][seat+1:]
                          switch_to_occupied.append([row,seat])
  
                      # check for occupied
                      if grid[row][seat] == '#' and len([x for x in adjacent_seats if x == '#']) >= 4:
                          # grid[row] = grid[row][:seat] + 'L' + grid[row][seat+1:]
                          switch_to_empty.append([row,seat])
  
  
  
              # print(grid)
  
              # print(switch_to_occupied)
              # print(switch_to_empty)
  
              for seat in switch_to_occupied:
                  grid[seat[0]] = grid[seat[0]][:seat[1]] + '#' + grid[seat[0]][seat[1]+1:]
  
              
              for seat in switch_to_empty:
                  grid[seat[0]] = grid[seat[0]][:seat[1]] + 'L' + grid[seat[0]][seat[1]+1:]
  
              return grid
  
  
          for i in range(100):
              seating()
  
          c = 0
          for x in grid:
              c += len([y for y in x if y == '#'])
  
  
          return c
  
  
  if __name__ == '__main__':
      s = solve_day()
  
      print(f'Part 1: {s.part1()}')
      # print(f'Part 2: {s.part2()}')