[200th mission] DFS and great neighbors function solution in Clear category for Safe Coasts by Phil15
from itertools import product
MOVES = [move for move in product((-1,0,1), repeat=2) if move!=(0,0)] # 8 moves
SHIP_MOVES = [(i,j) for (i,j) in MOVES if abs(i)+abs(j)==1] # 4 moves N-S-E-W
WATER, LAND, DANGER, SAFE = '.XDS'
"""Know coasts then ghost territory (with DFS). What remains is safe."""
r, c = len(map), len(map)
neighbors = lambda i, j, moves, elem: ((i+I, j+J) for I, J in moves
Sept. 18, 2018