Backtracking 4: Deduplication, another way of writing, rearranging the itinerary, N queens, solving Sudoku

18. Another way to write backtracking problem deduplication If it is repeated under the same parent node, the subset problem must be sorted. You can use set to deduplicate this layer. If it is reloaded from the parent node in this layer, the used array should be written in backtracking, and the backtracking is preceded […]

Sudoku (16*16) DFS pruning optimization solution

DFS special collection: DFS Connectivity Model DFS pruning and optimization It is said that filling Sudoku with DLX is the fastest, I don’t know DLX, so I use DFS and optimize infinitely. Only some optimization operations are described here. One: Optimization order: With 9*9 Sudoku, we find the lattice point that can be filled with […]

Python uses Sudoku skills to solve Sudoku-automatically read and fill in the questions and the next level

WeChat Mini Program: Sudoku Game Jiugongge #Algorithm 1.py import numpy as np import copy from itertools import combinations class points: def __init__(self, row, column): self.line = line self.column = column self.palace=row//3*3 + column//3 Candidates in self.=[*range(1,10)] class Sudoku: def __init__(self, sudoku): self.sudoku=sudoku self.cell to be filled=initPoint(sudoku) self.filled cell=[] self.exist valid method=True class has no candidates […]

Sudoku Verification* – Solvable Sudoku

Valid and Solved Sudoku Sudoku Verification* Title English This is a challenge of the University of Sydney, completed all the test cases You are tasked with writing a program that will verify that a sudoku puzzle is solvable. If you are unfamiliar with sudoku, Sudoku is a puzzle game that requires the player to place […]

Valid Sudoku, please determine whether a 9 x 9 Sudoku is valid. You only need to verify whether the filled numbers are valid according to the following rules.

Title: Please determine whether a 9 x 9 Sudoku is valid. You only need to verify whether the filled numbers are valid according to the following rules. The numbers 1-9 can only appear once per line. The numbers 1-9 can only appear once in each column. Numbers 1-9 can only appear once in each 3×3 […]

P1074 [NOIP2009 Improvement Group] Target Sudoku

Daily macro #define Archmage dfs Long live the Archmage Title Title background This is an ancient problem, and there is no guarantee that there is a program that can pass any input data that meets the requirements. Description of topic Both Xiaocheng and Xiaohua are good students who love mathematics. Recently, they have become obsessed […]

Target Sudoku (dfs)

[NOIP2009 Improvement Group] Target Sudoku Title background This is an ancient problem, and there is no guarantee that there is a program that can pass any input data that meets the requirements. Description of topic Both Xiaocheng and Xiaohua are good students who love mathematics. Recently, they have become obsessed with the game of Sudoku. […]

#2591. 「NOIP2009」Target Sudoku

[NOIP2009 Improvement Group] Target Sudoku Title background This is an ancient problem, and there is no guarantee that there is a program that can pass any input data that meets the requirements. Description of topic Both Xiaocheng and Xiaohua are good students who love mathematics. Recently, they have become obsessed with the game of Sudoku. […]