Optimal minesweeper solver