| 55 | |
| 56 | """ |
| 57 | class Solution(object): |
| 58 | def makeAround(self, x, y): |
| 59 | # if x - 1 >= 0 and y - 1 >= 0 and x + 1 < x_maxes and y + 1 < y_maxes: |
| 60 | # return True |
| 61 | # right left down up |
| 62 | return [(y, x-1), |
| 63 | (y, x+1), |
| 64 | (y-1, x), |
| 65 | (y+1, x)] |
| 66 | # return False |
| 67 | |
| 68 | def solve(self, board): |
| 69 | """ |
| 70 | :type board: List[List[str]] |
| 71 | :rtype: void Do not return anything, modify board in-place instead. |
| 72 | """ |
| 73 | # return board |
| 74 | |
| 75 | if not board: |
| 76 | x_length = 0 |
| 77 | else: |
| 78 | x_length = len(board[0]) |
| 79 | y_length = len(board) |
| 80 | |
| 81 | def translate_o_to_e(x, y): |
| 82 | # pass |
| 83 | # coordinate = self.makeAround(x, y) |
| 84 | # if coordinate: |
| 85 | for i in self.makeAround(x, y): |
| 86 | if i[0] >= 0 and i[1] >= 0 and i[0] < y_length and i[1] < x_length: |
| 87 | if board[i[0]][i[1]] == "O": |
| 88 | board[i[0]][i[1]] = "E" |
| 89 | translate_o_to_e(i[1], i[0]) |
| 90 | |
| 91 | # up down |
| 92 | e_coordinate = [] |
| 93 | for i in range(x_length): |
| 94 | if board[0][i] == 'O': |
| 95 | board[0][i] = 'E' |
| 96 | translate_o_to_e(i, 0) |
| 97 | |
| 98 | if board[y_length-1][i] == "O": |
| 99 | board[y_length-1][i] = 'E' |
| 100 | translate_o_to_e(i, y_length-1) |
| 101 | |
| 102 | # left right |
| 103 | for i in range(y_length): |
| 104 | if board[i][0] == 'O': |
| 105 | board[i][0] = 'E' |
| 106 | translate_o_to_e(0, i) |
| 107 | |
| 108 | if board[i][x_length-1] == 'O': |
| 109 | board[i][x_length-1] = 'E' |
| 110 | translate_o_to_e(x_length-1, i) |
| 111 | |
| 112 | for y in range(y_length): |
| 113 | for x in range(x_length): |
| 114 | if board[y][x] == 'E': |
nothing calls this directly
no outgoing calls
no test coverage detected