diff --git a/JEOH/51to60/53.py b/JEOH/51to60/53.py index e69de29..5c31f9f 100644 --- a/JEOH/51to60/53.py +++ b/JEOH/51to60/53.py @@ -0,0 +1,30 @@ +def solution(board, aloe, bloc): #해결못해서 답지참고함 + ROW, COL = len(board), len(board[0]) + DR, DC = [-1, 0, 1, 0], [0, 1, 0, -1] + def is_valid_pos(r, c): + return 0 <= r < ROW and 0 <= c < COL + def recursive_func(alpha_pos, beta_pos, visited, step): + r, c = alpha_pos if step % 2 == 0 else beta_pos + can_move = False + is_opponent_winner = True + win_steps, lose_steps = [], [] + for i in range(4): + nr, nc = r + DR[i], c + DC[i] + if is_valid_pos(nr, nc) and (nr, nc) not in visited and board[nr][nc]: + can_move = True + if alpha_pos == beta_pos: + return True, step + 1 + win, steps_left = ( + recursive_func([nr, nc], beta_pos, visited | {(r, c)}, step + 1) + if step % 2 == 0 + else recursive_func( + alpha_pos, [nr, nc], visited | {(r, c)}, step + 1 + ) + ) + is_opponent_winner &= win + (win_steps if win else lose_steps).append(steps_left) + if not can_move: + return False, step + if is_opponent_winner: + return False, max(win_steps) + return True, min(lose_steps) \ No newline at end of file diff --git a/JEOH/81to90/86.py b/JEOH/81to90/86.py new file mode 100644 index 0000000..e69de29 diff --git a/JEOH/81to90/87.py b/JEOH/81to90/87.py new file mode 100644 index 0000000..e69de29 diff --git a/JEOH/81to90/88.py b/JEOH/81to90/88.py new file mode 100644 index 0000000..e69de29 diff --git a/JEOH/81to90/89.py b/JEOH/81to90/89.py new file mode 100644 index 0000000..e69de29 diff --git a/JEOH/81to90/90.py b/JEOH/81to90/90.py new file mode 100644 index 0000000..e69de29