가전디지털, 여행시즌 액세서리 SALE

가이드문구

[코드코드] 수도쿠-Blue

  • 2024-07-10 03:27:33
  • 리뷰(0)

가이드문구

```python def sudoku(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, 0, 0, 0, 2, 8, 0], [0, 0, 0, 4, 1, 9, 0, 0, 5], [0, 0, 0, 0, 8, 0, 0, 7, 9] ] solve(board) print_board(board) def solve(board): find = find_empty(board) if not find: return True else: row, col = find for num in range(1, 10): if is_valid(board, num, (row, col)): board[row][col] = num if solve(board): return True board[row][col] = 0 return False def is_valid(board, num, pos): for i in range(len(board[0])): if board[pos[0]][i] == num and pos[1] != i: return False for i in range(len(board)): if board[i][pos[1]] == num and pos[0] != i: return False box_x = pos[1] // 3 box_y = pos[0] // 3 for i in range(box_y*3, box_y*3 + 3): for j in range(box_x * 3, box_x*3 + 3): if board[i][j] == num and (i,j) != pos: return False return True def print_board(board): for i in range(len(board)): if i % 3 == 0 and i != 0: print(\

가격·재고는 판매 페이지 기준으로 실시간 변동될 수 있습니다.
최신 정보는 상세 페이지에서 확인하세요.