Premium problem52. Minesweeper: Adjacent Counts

Hard Locked

Add an 'adjacent' column giving the number of mines on the (up to 8) adjacent squares, for the seeded 5×4 grid from the previous puzzle (rebuild it the same way: np.random.seed(0) immediately before drawing the mines, inside solve). Return the DataFrame with the counts as integers.

Output

    x  y  mine  adjacent
0   0  0     0         2
1   0  1     1         2
2   0  2     1         3
3   0  3     0         2
4   1  0     0         3
.. .. ..   ...       ...
15  3  3     0         3
16  4  0     0         2
17  4  1     1         2
18  4  2     1         3
19  4  3     1         1

[20 rows x 4 columns]

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)