new_contents: #!/usr/local/bin/python
  # Code Fights Add Border Problem
  
  
  def minesweeper(matrix):
      num_mines = []
      rows = len(matrix)
      cols = len(matrix[0])
      adj = [-1, 0, 1]
      for r in range(rows):
          curr_row = []
          for c in range(cols):
              curr_row.append(sum([matrix[r + i][c + j] for i in adj if (r + i >= 0 and r + i < rows) for j in adj if (c + j >= 0 and c + j < cols and not(i == 0 and j == 0))]))
          num_mines.append(curr_row)
  
      return num_mines
  
  
  def main():
      tests = [
          [
              [
                  [True, False, False],
                  [False, True, False],
                  [False, False, False]
              ],
              [
                  [1, 2, 1],
                  [2, 1, 1],
                  [1, 1, 1]
              ]
          ],
          [
              [
                  [False, False, False],
                  [False, False, False]
              ],
              [
                  [0, 0, 0],
                  [0, 0, 0]
              ]
          ],
          [
              [
                  [True, False, False, True],
                  [False, False, True, False],
                  [True, True, False, True]
              ],
              [
                  [0, 2, 2, 1],
                  [3, 4, 3, 3],
                  [1, 2, 3, 1]
              ]
          ]
      ]
  
      for t in tests:
          res = minesweeper(t[0])
          if t[1] == res:
              print("PASSED: minesweeper({}) returned {}"
                    .format(t[0], res))
          else:
              print("FAILED: minesweeper({}) returned {}, should have returned {}"
                    .format(t[0], res, t[1]))
  
  
  if __name__ == '__main__':
      main()
  
subject: Solve Code Fights minesweeper problem