Problem 96
Su Doku
Su Doku (Japanese meaning number place) is the name given to a popular puzzle concept. Its origin is unclear, but credit must be attributed to Leonhard Euler who invented a similar, and much more difficult, puzzle idea called Latin Squares. The objective of Su Doku puzzles, however, is to replace the blanks (or zeros) in a $9$ by $9$ grid in such that each row, column, and $3$ by $3$ box contains each of the digits $1$ to $9$. Below is an example of a typical starting puzzle grid and its solution grid.
A well constructed Su Doku puzzle has a unique solution and can be solved by logic, although it may be necessary to employ “guess and test” methods in order to eliminate options (there is much contested opinion over this). The complexity of the search determines the difficulty of the puzzle; the example above is considered easy because it can be solved by straight forward direct deduction.
The 6K text file, sudoku.txt(right click and ‘Save Link/Target As…’), contains fifty different Su Doku puzzles ranging in difficulty, but all with unique solutions (the first puzzle in the file is the example above).
By solving all fifty puzzles find the sum of the $3$-digit numbers found in the top left corner of each solution grid; for example, $483$ is the $3$-digit number found in the top left corner of the solution grid above.
数独
数独(日语原意为数的位置)是一种热门的谜题。它的起源已不可考,但是与欧拉发明的一种类似而更加困难的谜题拉丁方阵之间有着千丝万缕的联系。数独的目标是替换掉$9 \times 9$网格中的空白位置(以数字$0$表示),使得每行、每列以及每个九宫格中恰好都包含数字$1$至$9$。如下是一个典型的数独谜题以及它的解答。
一个构造精良的数独谜题应该有唯一解,且能够通过逻辑推断来解决,尽管有时需要通过“猜测并检验”来排除一些选项(对于这一点目前仍有争议)。寻找答案时的复杂程度决定了题目的难度;如上这个谜题被认为是简单的谜题,因为解决该题只需要直接的演绎推理即可。
在文本文件sudoku.txt中包含有五十个不同难度的数独谜题,但保证它们都只有唯一解(文件中的第一个谜题就是上述样例)。
解开这五十个谜题,找出每个谜题解答左上角的三个数字所构成的三位数,并求这些数的和;比如,上述样例解答对应的三位数就是$483$。