Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU

 
CONTINUE READING
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

Creating Sudoku Puzzles

   China, Shanghai Foreign Language School
                                          Affiliate to SISU
                                    Professor: Yue SUN
                        Team Member: Bing GAN
                                            Taokun ZHENG

                           1 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

Summary
                             Creating Sudoku puzzles

Sudoku is gaining the most popularity than ever before from not only mathematicians or High-IQs,
but also common citizens. It stimulates one's mind as well as provide a refreshment for his or her
stressful life. However, since some puzzles of Sudoku are easy to solve while others may take
enormous amount of time and attention, it would be really helpful for people, who enjoy Sudoku
on different purposes with different aptitude, to classify Sudoku puzzles into various levels.
Therefore, we build the mathematic model to create the puzzles labeled "Easy", "Medium",
"Hard", or "Expert".

In order to create appropriate Sudoku puzzles and to divide them into the four levels , we firstly
studied how real people solve a puzzle, and transformed such method into a systematic model. In
the model, We generalized five operations (1st / 2nd / 3rd Grade Logic and Non-Logic Operation)
and the circulation of the five operations.

After we elaborately defined our four levels (Easy, Medium, Hard and Expert) on the base of the
systematic model of solving a puzzle, we mainly focused on the model of creating an eligible
puzzle which has only one solution. We believe that all proper Sudoku puzzles should just have
one solution. We demonstrate what features are required for an eligible puzzle.

Finally, we start to build the model of creating eligible puzzle of different levels according to the
definition of our four levels, the model of solving a puzzle and the requirements for an eligible
puzzle. Two methods are used here: the transformation of puzzles and the reverse use of the
systematic model of solving a puzzle.

The transformation of puzzles is used to transform a given puzzle of a particular level and its
solution grids into a brand-new puzzle and its solution of exactly the same level, by utilizing
methods of digit exchanging, rotation, rows-in-a-band exchanging, columns-in-a-stack exchanging
band exchange and stack exchange. The purpose of this whole transformation method is to create
puzzles of the third and forth level (Hard and Expert).

As for puzzles of the first and second level (Easy and Medium), we introduced the reverse use of
solving a puzzle, by hollowing cells that are not the ensuring digits of the 1st and 2nd Grade Logic
Operation.

We used a myriad of pictures to help illustrate our model and applied the methods on Computer
Programming (PASCAL). All these proved that our model is feasible both in theory and in reality.

                                                2 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                                      Contents
I.           Introduction……………………………………………...4
II.          Terminologies of Sudoku………………………………..5
III. Starting from Solving the Puzzles……………………...7
      i.       Transform the solving techniques used by human beings into a

               systematic model……………………..…………………...7

      ii.      Algorithm for solving a puzzle………..…………………......7

IV. Dividing puzzles into Four Difficulty Levels…………12
V.           Creating a Puzzle………………………………………13
      i.       Transform puzzles and solution grids……………………….13

      ii.      Creating a solution grid without similarity…………………...14

VI. Making an Eligible Sudoku Puzzle…………………...15
      i.       Elements of creating a puzzle…............................................15

      ii.      Finding hidden rules of producing a puzzle with only one solution.17

      iii.     Our algorithm for producing a puzzle with a unique solution……18

VII. Evaluation…………………………………………………..22

VIII. Extensions………………………………………………22
IX. References………………………………………………25
X.           Appendix………………………………………………..25
      i.       Algorithms of Pascal……………………………………..25

      ii.      Rest pictures showing the process of deducing………………...38

                                             3 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

I.     Introduction
Sudoku has become one of the best-known games of logic nowadays. Though the
name comes from Japanese, its original form can be traced back to the concept of
Magic Squares appeared at the end of the ninth or early tenth century A.D. During the
study of Magic Squares in 1783, the Swiss mathematician Leonard Euler developed
Latin Squares, in which one Latin word in each row and column should appear no
more than once. In 1970s, editors of a US magazine invented and published a new
kind of puzzle based on Euler’s Latin Squares, which was known as the Number
Place. Later, traveling to Japan in 1980s, the puzzle was named Sudoku by the locals.
Since then, it has been popular among all classes of society in Japan and around the
world. The rule of the game is that the player needs to fill a 9×9 grid so that numbers
1 through 9 appear in each row, column and smaller 3×3 grid called “region” or
“box” with no duplication. Since it comes in numerous varieties and requires high
level reasoning ability, more and more mathematicians have drawn attention to this
sort of puzzle. However, the game has also attracted millions of common people from
the age of nine to ninety-nine due to its easily-comprehensible rule.

Different difficulty levels of Sudoku puzzles can meet the demand of various players,
making them steadily master the techniques of this amazing game and then enjoy it as
soon as possible. That is why almost every website and software of Sudoku game
offers all kinds of puzzles from the easiest to the hardest. Therefore, our algorithm can
create puzzles in four different grades: Easy, Medium, Hard and Expert.

In our model, we classify puzzles based on the techniques required to solve them.
When making a puzzle, we start from producing a solution grid and then blank out the
cells. Before a puzzle is finally created, logic operations and non-logical operations
are imported on the base of different techniques used by human beings in the order of
their complexity, thus ensuring that this puzzle has only one unique solution.

                                          4 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

II. Terminologies of Sudoku

                                        Fig 2-1
1. Cell: A single square in the puzzle where
    one digit can be placed
2. Grid: The full 9×9 set of cells
3. Row: 9 cells of the puzzle running in a
    straight line from left to right
4. Column: 9 cells of the puzzle running in
    a straight line from top to bottom.
5. Region: One of the 3 by 3 squares of
    cells in the grid when it is divided into
    nine equal squares.(Fig 2-2)
[Codes are assigned to each row, column or
region of a Sudoku grid. The rows from the
                                                                    Fig 2-2
                                        upper to the lower are named with numbers
                                        1 through 9 in turn. The columns from the
                                        left to the right are named from 1 to 9 in turn.
                                        The regions are named from A to I.]
                                        6. Group: A box, row or column
                                        7. Boxcol: Group of 3 cells lined up in the
                                             intersection of a region and a column
                                        8. Boxrow: Group of 3 cells lined up in the
                                             intersection of a region and a row
             Fig 2-3                  9. Band: Three boxes connected horizontally
to make a 9 by 3 rectangle. (Fig 2-3)
10. Stack: Three boxes stacked vertically to make a 3 by 9 rectangle. (Fig 2-3)
                                         5 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

11. Chute: Either a band or a stack
12. Given: Givens are the numbers which are filled into the grid to begin with. These
    are not to be changed in the course of completing the puzzle.
13. Value: The digit as a property of a specific cell. Thus, the value of a cell can be
    one of the available digits, or nothing, when the cell is unsolved. The phrase
    “Digit 6 is placed in R1C8” is equivalent to “The value of R1C8 is 6”
14. Solution grid: A 9×9 grid with digits 1 through 9 appearing in each row, column
    and region without duplication
15. Single: A cell with only one candidate
16. Pair: Two cells in the same group with only the same two candidates
17. Hidden pair: When two digits have been eliminated from all but two cells in a
    group all other digits can be eliminated from those cells
18. Hidden single: A digit can be placed when it is eliminated from all but one cell in
    a group
19. Naked pair: When two cells in a group can only contain the same two digits,
    those digits can be deleted from all other cells in the group
20. Naked single: When a digit
    is known in a cell it can be
    eliminated from all other
    cells in groups containing
    that cell
21. Locked candidates: When a
    digit in a box is restricted to
    the intersection with a
    column or row, it can be
    eliminated from the other
    cells in the column or row
22. Similar 2-cell combination:
    The combination of two
    digits and the other two with

                                        the locations of the original
                                                                     Fig 2-4
                                        ones exchanged in another row or column of
                                        the same chute. (Fig 2-4)
                                    23. Similar 3-cell combination: The combination
                                        of three original digits and the other three with
                                        the locations of the original ones exchanged in
                                        another row or column in the same chute (Fig
                                        2-4)
                                    24. Inappropriate solution grid: A solution grid
    whose permutations of the digits tend to be
             Fig 2-5                     similar in each band or stack. (Fig 2-5)
25. Ensuring digit: A digit that ensures that the Sudoku puzzle has a unique solution
                                          6 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

26. Remaining digit: A digit in a Sudoku puzzle that is not an ensuring digits

III. Starting from Solving the Puzzle
For the purpose of finding out the logic of all the values in Sudoku, we have to
comprehend how to solve a puzzle initially. When working out a puzzle, Sudoku
players often use various techniques to avoid repetitive steps, but a solving algorithm
needs a series of circulating stages to function operations. After observing the
common techniques used by most players, we develop a logic system that can be used
in the solving algorithm. The system can help the algorithm solve Sudoku puzzles as
efficiently as possible.

Some digits can be placed as the values of the cells through direct observation on the
puzzle, and we conclude it as the Basic-grade Logic Operation. Afterwards, we need
further observation to place the digits as the values of some of the rest blank cells.
This step is more complex. We need to figure out the logic inside a group, and we
conclude it as the First-grade Logic Operation. Some more sophisticated techniques
may be used if one wants to place more digits as the values of the cells or eliminate
more candidates in the cells when solving difficult puzzles. We conclude it as the
Second-grade Logic Operation. These operations will be introduced in the following.

i.     Transform the solving techniques used by human
       beings into a systematic model
We develop a “candidate deleting system” based on the solving techniques, which
first fills all the blank cells with numbers 1 through 9 and then eliminates all the
                                                       improper candidates based on
                                                       the logic in every group.

                                                        ii.     Algorithm         for
                                                                solving a puzzle

                                                        Our principle of puzzle
                                                        solving in an algorithm
                                                        The principle of solving a
                                                        puzzle in an algorithm is to
                                                        eliminate all the incorrect
                        Fig 3-1                         candidates in each cell step by
step. Thus we grade a series of repetitive operations for the computer to remove the
unnecessary candidates from a grid:
1. Basic-grade Logic Operation

                                         7 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                                      Fig 3-2

                                     Fig 3-3
Eliminate all the incorrect candidates based on the givens. Since it is limited that
the same digit can appear no more than once in the same group, the candidates in
each cell that also appear in the group that it belongs to should be deleted first.
( Fig 3-1 Fig 3-2)

                                      8 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                                         Fig 3-4
2. First-grade Logic Operation

   Direct operation: When only one candidate still remains in a specific cell ( a
   naked single, see p.4), it can be placed as the value of the cell. (Fig 3-3)

                                         Fig 3-5
   Inverse operation: If one
   candidate in a specific cell
   does not appear in other cells
   of the same group( a hidden
   single, see p.4), it can be
   placed as the value of the cell.
   (Fig 3-4 Fig 3-5)

3. Second-grade           Logic
   Operation
   Direct operation: Observe the
   candidates in the same group.                      Fig 3-6
                                         9 / 46
Creating Sudoku Puzzles - China, Shanghai Foreign Language School Affiliate to SISU
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

If the two same candidates only appear in two cells of the same group (a naked pair,
     see p.4), other candidates in the two cells should be deleted. The two candidates
                                         Fig 3-7

   can be set as the only potential values in the two cells. (Fig 3-6 Fig 3-7)

   Opposite operation: Observe the candidates in the same group. If two cells in the
   same group only contain the two same candidates (hidden pair, see p.4), they can
   be set as the only potential values in the two cells. Eliminate the two candidates in
   other cells of the same group.

4. Third-grade Logic Operation
   Direct operation: Observe the candidates in the same group. If three cells in the
   same group only contain the two or three same candidates, they can be set as the
   only potential values in the three cells. Eliminate the two candidates in other cells
   of the same group.
                                        Opposite operation: Observe the candidates in
                                        the same group. If the two or three same
                                        candidates only appear in three cells of the
                                        same group, other candidates in the three cells
                                        should be eliminated. The two or three
                                        candidates can be set as the only potential
                                        values in the three cells.

                                      By analogy, higher-grade logic operations
                                      exist theoretically. However, due to the
                                      restriction of the size of the 9 × 9 grid,
                                      Third-grade Logic Operations are hardly used
              Fig. 3-8                 in the actual process of puzzle solving in a
computer, and higher-grade logic operations no more need to be demonstrated here.

                                          10 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

5. The circulation of the solving algorithm
When solving a puzzle, the algorithm functions the Basic-grade Logic Operation, the
First-grade Logic Operation and the Second-grade Logic Operation in turn. When a
candidate is placed as the value in a cell during the process, the algorithm starts to
function the Basic-grade Logic Operation again. By analogy, the algorithm repeats
functioning ceaselessly as a circulation until all the candidates are placed as the values
of the cells or Non-logic Operations starts to be functioned, which will be illustrated
in the following.( Fig 3-8 Fig 3-9)

                                       Fig 3-9
If no candidates can be placed as the value of any cell after functioning all the Logic
Operations, or, in other word, no further Basic-grade Logic Operations, First-grade
Logic Operations and Second-grade Logic Operations can be run, the algorithm will

                                          11 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

starts to function Non-logic Operations. It attempts to place all candidates one by one
in a cell in order to figure out whether the candidate is the value of the cell until a
correct candidate is set as the value of the cell.

IV. Dividing puzzles into Four Difficulty
    Levels
First, it must be realized that the total ndddumber of the givens in a puzzle is not a key
element in grading the difficulty level of a puzzle. It is very common to find 34 givens
in a puzzle that is graded at the “expert” level. Meanwhile, an “easy” puzzle may only
contain 30 givens. Actually, there are mainly two determining factors influencing the
grading of the difficulty level of a Sudoku puzzle: the positions and the total numbers
of the ensuring digits.

The result is useful in creating a puzzle by hand. However, the set of steps is too
complicated for an algorithm to function; therefore, it is necessary to convert the
present process into a series of operations that can be functioned in a computer. As the
positions and the total number of the ensuring digits influence the process of puzzle
solving, thus affecting the difficulty level, the concept of logic operations can be
imported to grade the difficulty level of Sudoku puzzles created by the algorithm.

Level one “Easy”:
Puzzles at this difficulty level can be solved fairly easily during the direct observation
on the distribution of all the givens. Digits can be placed as values of the cells directly
as long as the player knows the rule of Sudoku games. Solving puzzles at the level of
“easy” requires few techniques. As the Basic-grade Logic Operation is developed on
the base of the direct observation during the process of solving a puzzle by human
beings, “easy” Sudoku puzzles are defined as puzzles that should be solved with
Basic-grade Logic Operations only by the algorithm.

Level two “Medium”:
Further observation on the puzzle and some simple techniques are required after the
direct observation when the player tries to work out a puzzle at the level of “medium”.
As the First-grade Logic Operation is developed on the base of further observation
during the process of solving a puzzle by human beings, “medium” Sudoku puzzles
are defined as puzzles that should be solved with both Basic-grade Logic Operations
and First-grade Logic Operations by the algorithm.

Level three “Hard”:
“Hard” Sudoku puzzles are more challenging than the first and the second difficulty
level. It requires not only careful observation but also some complicated techniques
during the process of solving the puzzles. As the Second-grade Logic Operation is

                                           12 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

developed on the base of those techniques, puzzles that should be solved with
Basic-grade Logic Operations, First-grade Logic Operations and Second-grade Logic
Operations by the algorithm can be defined as puzzles at the difficulty level of “hard”.

Level four “Expert”:
When solving a Sudoku puzzle at the level of “expert”, the player needs to combine
all kinds of techniques and to be patient with the digits. Since there are many
uncertainties during the process of working out the puzzle, Third-grade Logic
Operations and higher-grade logic operations may be imported sometimes. It is also
necessary for the computer to solve the problem with Non-logic Operations. Thus a
puzzle at the difficulty level of “expert” is one that should be solved by the algorithm
with a combination of Basic-grade Logic Operations, First-grade Logic Operations,
Second-grade Logic Operations, Third-grade Logic Operations, higher-grade logic
operations and Non-logic operations.

V. Creating a Puzzle
Our method to create a puzzle starts from producing a solution grid in order to avoid
contradiction during the process of solving. Thus we transform one solution grid
initially so as to diversify the puzzles as much as possible so that the solution grids
can come in a great many varieties.

i.     Transform puzzles and solution grids
(See Transformation of solution grids in appendix, p.36)

One solution grid can be transformed through digit exchanging, rotation,
rows-in-a-band exchanging, columns-in-a-stack exchanging, band exchanging, stack
exchanging and the combination of these six methods, none of which will affect the
correctness of all the derivatives of one certain solution grid, since the nature of the
grid is not influenced.

1. Digit exchanging
   It is simple to accomplish the method of digit exchanging, because what is
   necessary is to exchange all the digits in the cells of one solution grid. The change
   will not influence the uniqueness of a certain solution grid. I.e. replace all 1s in the
   grid into 8s, and then replace all 3s in the grid into 6s, and then replace all the 9s
   in the grid into 7s, etc. Thus a new Sudoku puzzle can be produced. Different
   puzzles of one solution grid come into existence in this way.

2. Rotation
   In this method, the solution grid can be rotated at an angle of 90 degrees, 180

                                           13 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

      degrees or 270 degrees to produce a new grid. This change will not influence the
      correctness of a certain solution grid.

3. Rows-in-a-band exchanging and columns-in-a-stack exchanging
   Rows-in-a-band exchanging means exchanging two or three rows in the same
   band randomly and columns-in-a-stack exchanging means exchanging two or
   three columns in the same stack randomly. After the exchange of the rows in the
   same band and the columns in the same stack, the newly made puzzle is still a
   correct one. This change will not influence the correctness of a certain solution
   grid.

4. Band exchanging and stack exchanging
   The methods of exchanging the bands and the stacks randomly are called band
   exchanging and stack exchanging. Any grid that is transformed in this way will
   still remain correct. This change will not influence the correctness of a certain
   solution grid.

5. The combination of the six methods
   If the six methods are combined and performed on one certain solution grid, a
   brand new grid can be produced with no influence on its correctness. i.e. Firstly,
   exchange digits 1,2,3,4,5,6,7,8,9 into 7,3,6,5,4,8,2,9,1, and then rotate the puzzle
   at the angle of 270 degrees. Exchange row 4 and row 6, row 7 and row 8, column1
   and column 2, as well as column 8 and column 9 afterwards. Finally, interchange
   the first band with the second band, as well as the second stack with the third
   stack After all these stages, a new solution grid will be created. A puzzle can also
   be transformed in this way. (Fig 5-1)

Fig 5-1

ii.       Creating a solution grid without similarity
(See Creating a grid solution randomly in Appendix, p.26)

Through six methods of transformation, we can create many derivatives of a certain
                                          14 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

solution grid. But this process won’t disorder an inappropriate (see p.13) solution grid
into an appropriate one. Appropriate solution grid can be stored in the database in
advance, and derivatives of the grids can be produced after the use of the
transformation methods. However, the total number of the appropriate solution grids
stored in the database is strongly limited. That’s why a computer algorithm is needed
to create a solution grid randomly. Due to the lack of our time, we didn’t explain the
algorithm carefully in our paper.

VI. Making an Eligible Sudoku Puzzle

i.     Elements of creating a puzzle

Every Sudoku puzzle produced by the algorithm is made by blanking out some
particular digits in the cells at a particular location from a solution grid, instead of
adding numbers to an empty grid at random. No matter how a puzzle is created,
several rules need to be abided by.

                                                   1. We      shouldn’t       use     an
                                                      inappropriate solution grid (Fig
                                                      6-1) as the final solution grid of
                                                      a puzzle. Solution grids whose
                                                      permutations of the digits appear
                                                      to be irregular are strongly
                                                      needed.

                                                 2. Removing too many givens
                                                    from a solution grid may lead to
                                                    several different solutions of the
                                                    same Sudoku puzzle during the
                                                    process of solving. Theoretically,
                                                    when a puzzle provides 21 or
                                                    more givens randomly in the
                                                    beginning, the probability of
                                                    producing a unique solution grid
                                                    will rise substantially. Actually,
                      Fig 6-1                        17 particular givens at certain
locations can result in a unique solution, but the total of 17-given puzzles with a
unique solution is limited. (Fig 6-2)

3. The maximum of the givens in a Sudoku puzzle can influence the difficulty level
   to some extent. More givens may help solve the puzzle more easily. Theoretically,

                                         15 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

   the    limitation    of  the
   maximum of the givens is 45,
   since a puzzle with givens
   over 45 does not require
   high-level reasoning and is
   unnecessary to be discussed.
   Therefore, puzzles provided
   with givens more than 45 will
   not appear in our paper.

4. There is a misunderstanding
   that the given numbers and
   the positions of them should
   be distributed as evenly as                              Fig 6-2
   possible. But what is the fact? If the givens appear improperly, several solutions
   will be accomplished. All the solutions to the same improper puzzle are
   transformations of an original grid. The following measures can help avoid the
   situation: (Fig 6-3 Fig 6-4 Fig 6-5)
   a). The cells in two or three rows of
   the same band should not be all blank.
   The cells in two or three columns of
   the same stack should not be all blank.
   b).The givens in the puzzle should
   include at least eight of the digits from
   1 to 9. I.e. the situation that both the
   digits 1 and 2 do not appear as givens
   in a Sudoku puzzle is not allowed.
   c).At least one similar two-cell
   combination or one similar three-cell
   combination must appear in the puzzle.
   If none of the elements above appears
   in the puzzle, Sudoku players can work
   out several solutions to the same
   puzzle by exchanging digits in the cells.                 Fig 6-3

5. Additionally, puzzles unevenly distributed fulfilling the elements mentioned
   above may still have several solutions, which means, creating an eligible puzzle is
   far more complicated.

                                        16 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                                 Fig 6-4

ii.    Finding hidden rules of producing a puzzle with only
       one solution

                                             Fig 6-5
After a solution grid has been established, we can start creating a puzzle. An eligible
puzzle always requires a unique solution. Making a puzzle with only one solution is a
difficulty that we need to overcome. In other word, it is complicated to blank out the
cells in a solution grid. We try to accomplish it centrally symmetrically: blanking out
a cell in the solution grid as well as another cell centrally symmetrically about the cell.
This method provides a standard process of creating a puzzle and is easy to solve, but
it still can’t guarantee a unique solution. What is the hidden element of producing a
puzzle with only one solution? We study the logic operations in order to figure it out.

When blanking out a cell, what happens to the original puzzle? The appearance or
                                           17 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

disappearance of a digit in a cell influences the candidates of the blank cells in the
same group. With more cells blanked out, the total number of the candidates in other
blank cells increases. Different numbers that are blanked out and different positions in
which these numbers are located also have an impact on the candidates of the blank
cells in the same group. If all the digits blanked out can be inferred by the existing
givens, the puzzle will have only one unique solution.

If a Sudoku puzzle that has only one solution can be directly worked out by using
Basic-grade Logic Operations and First-grade Logical Operations, we can distinguish
the digits that should be blanked from the ones that should be reserved through
inverse operations.

iii.   Our algorithm for producing a puzzle with a unique
       solution
(See Creating a puzzle at the level of “easy” and Algorithm in mathematical language,
in Appendix, p.23&28)

                                       In this paper, we attempt to make a puzzle with
                                       a unique solution based on the techniques used
                                       by human beings to solve the puzzle. When
                                       working out a puzzle of the “Easy” level, only
                                       First-grade Logic Operations are required.
                                       Also, seeing that our method is to make a
                                       puzzle based on the way of puzzle solving first,
                                       the best way to make a puzzle of the “Easy”
                                       level is to abide by the inverse operations of
                                       working out a puzzle.

                Fig A-0                At the very beginning, create a solution grid of
the puzzle that we are making. The solution grid is illustrated in Fig A-0.

Step 1: Choose a cell randomly, and blank out the digit. I.e. Blank the digit 8 in the
cell (5, 2), as illustrated in Fig A-1.

                                         18 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                                          Fig A-1
Step 2: Find out the logic between the digits in the 9 cells of Region C and the last
digit blanked out. In order to fix the same digit in that specific cell, the digit 4 in the
cell (9, 2) has to be reserved. Since we can fix the number 8 in the cell (5, 2) by
placing three digits in the cells (1, 1) (7, 7) (8, 4) of that region. The digit 4 that has to
be reserved is called an ensuring digit (shown in pink) in Fig A-2.

                                          Fig A-2
Due to the existence of the digit 4, they can place the digit 8 in the cell (5, 2) through
First-grade Logic Operations when people solve the puzzle, because the digit 8 is not
a candidate in other cells of this region.

Step 3: Find out the logic between the digits 4 fixed in step 3 and the next region
anticlockwise. We print the digit 7 in the cell (8, 5), which is also an ensuring digit as
                                            19 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

illustrated in Fig A-3.

                                                 Step 4 to 13: In the same way, we
                                                 mark all the ensuring digits in a
                                                 particular sequence. (Sequences of
                                                 creating different solution grids are
                                                 distinct.) (In the example illustrated,
                                                 there is an anti-clockwise sequence.)
                                                 The sequence is illustrated from Fig
                                                 A-4 to Fig A-13. (see Rest pictures
                                                 showing the process of deducing,
                                                 Appendix, p.38)
                                                 Step 14: Since more and more digits
                                                 are marked during the process of
                                                 successive markings, some digits in
                                                 the blank cells can be fixed directly
                                                 on the base of these ensuring digits.
                                                 i.e. When Step 14 is operated, the
                                                 digit 7 can be fixed in the cell (9, 7)
                       Fig A-3                     from the three 7s by First-grade
Logic Operation. Highlight the digit 7 with light blue, and blank it out at the end of
the stage. It is illustrated in Fig A-14.

                                       Fig A-14
Step 15 to 43: The steps of fixing the remaining numbers can be considered as the
validation of the uniqueness of the puzzle. Whenever an ensuring digit is fixed, find
out whether a remaining digit appears or not. According to the rules of First-grade
Logic Operations, a remaining digit will only show up after this digit has been marked
many times. i.e. In the last example, a remaining 7 appears in the puzzle when three

                                         20 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

7s in this puzzle are marked.
During this process, more and more ensuring digits and remaining digits will be
marked, the number of cells left blank will decreases, and eventually, all the numbers
in each cell will be marked as ensuring digits or remaining digits. The steps are
illustrated from Fig A-15 to Fig A-43. (See Rest pictures showing the process of
deducing, Appendix, p.38)
The ensuring digits must be made as givens in the puzzle, while cells with remaining
digits can be made as the blank cells in the puzzle. Finally, a puzzle with only one
answer is created. That this puzzle has one unique solution can be proved as
illustrated in Fig A 43,A-44.

                           Fig A-43
The figures illustrate the whole
process of creating a puzzle at the
level of “easy”. In the same way,
puzzles at medium level (level 2) can
be produced by a more complex
algorithm.
(See Creating a Sudoku at the level
of “medium”, in Appendix, p.30)
                           Fig A-44

                                        21 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

VII. Evaluation

i.        Strengths

1. Problems will hardly occur since we develop the puzzles according to the methods
       that computers use to solve a puzzle, while these methods are imported from the
       techniques human beings use to work a puzzle out.

2. Our method in the study maximizes the logic in making and solving a puzzle
       while considering the humanization at the same time.

3. We deeply analyzed the relationship between the elements in a Sudoku puzzle,
       including rows, columns and regions etc.

4. The principle we used to categorize the puzzles is very instinct. Every level
       distinguishes from each other obviously.

ii.       Weaknesses

1. We haven’t applied the Second-grade Logic Operation into Third-graded Logic
   Operation, so puzzles that are at higher levels still can not be created.

2. Some details in the algorithm like the repetition and elimination of certain digits
   haven’t been considered yet, which occasionally lead to the errors in our
   algorithms.

iii.      Improvements

1. Prepare some puzzles at level two and levels higher than that, develop more
   puzzles through the six ways of transformation.

2. Perfect the algorithms, finding countermeasures to errors and simplifying them.

                                           22 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

VIII. Extensions
Nowadays, new kinds of Sudoku puzzles are developed by Sudoku lovers and
designers everyday. These original Sudoku puzzles, including Diagonal Sudoku,
Even-Odd Sudoku, Greater Than Sudoku, Consecutive Sudoku, Jigsaw Sudoku etc.
that first emerge online or on newspapers, have also drawn many people’s attention
due to their distinct characteristics. Appearing absolutely different from the traditional
forms of Sudoku puzzles, these new kinds of Sudoku games have similar rules with
the original forms of this game. However, the diverse forms of the game affect the
difficulty of the distinct games. Thus, some of the newly-invented Sudoku puzzles are
harder to solve than the traditional puzzles and more interesting.

Cube Sudoku (Fig 8-1) :
A new kind of Sudoku puzzle called Cube Sudoku contains 3 facets of an ordinary
cube. Printed on each of the facets is a normal Sudoku puzzle. All the rules of a Cube
Sudoku are the same with normal Sudoku games except that Cube Sudoku requires all
the numbers on the neighboring edges of two facets should be the same.

                          Fig 8-1

Killer Sudoku (Fig 8-2):
When solving a killer Sudoku, you will need to fill the grid with numbers from
number 1 to number 9 in a way that can meet many conditions. Firstly, each row,
column, and nonet contains each number exactly once while no number can appear
more than once in a cage at the same time. Also, the sum of all numbers in a cage
must match the small number printed in it. Finally, in 'Killer X', an additional rule is
that each of the long diagonals contains each number once. Some simple killer

                                          23 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

Sudokus can be easier to solve than regular Sudoku puzzles while the hardest ones
may need several hours to solve.

                                                                   Fig 8-2
                                                                Fig 8-3
Jigsaw Sudoku (Fig 8-3):
The rules in a Jigsaw Sudoku are the same with the ones of a regular Sudoku puzzle,
but the regions in a Jigsaw puzzle look differently from the normal square shaped
regions. That is to say, a jigsaw puzzle requires the assembly of numerous small, often
oddly shaped, interlocking and tessellating pieces. Another special feature of this
game is that each piece has a small part of a picture, such as building, nature etc. on it
and when complete, a jigsaw puzzle produces a complete picture.

:                   Fig 8-4
                                                               (Fig 8-5)

                                          24 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

HyperSudoku (Fig 8-4):
Another variant of Sudoku puzzles is called HyperSudoku or “windoku” and “four
square Sudoku”. Just like other Sudoku puzzles, this game requires only logic ability
instead of mathematics skills. The rule of this game is very simple to understand.
Each digit should appear only once in the 9 rows, columns and regions. However,
there are 13 regions including 9 under laying 3x3 squares and the 4 overlaying in the
game.

Greater Than Sudoku(Fig 8-5):
In a Greater Than Sudoku puzzle, no number is given to the players; instead,
denotations appear on the edges between two cells. This feature distinguishes this
game from others, makes this game appealing to Sudoku lovers and causes this game
harder to work out at the same time.

                                  Diagonal Sudoku(Fig 8-6):
                                 A Diagonal Sudoku is also named taikakusen
                                 nanpure, Diagonal Line Number Place, Sudoku X,
                                 Kokonotsu, or Dell's Number Place Challenger. You
                                 should attempt to fill in the grid so that every row,
                                 column, 3x3 box, and main diagonal contains the
                                 digits 1 through 9 when playing this game. Since
                                 this is a new game, firstly appeared in the early
                                 1990s, the minimal number of givens is for
                                 Diagonal Sudoku hasn’t been determined now.

             Fig 8-6

IX. References
Terminologies of Sudoku:
http://bofhp.blogbus.com/logs/6878291.html
Generating the solution grids:
http://163.19.31.3/cgi-bin/jancgi/getTemplet.cgi?player=&op=2062
Extensions of Sudoku:
http://www.maa.org/editorial/mathgames/mathgames_09_05_05.html
Introduction of Sudoku
www.conceptispuzzles.com/articles/Sudoku

X. Appendix

i.     Algorithms of Pascal
                                        25 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

1.Creating a grid solution randomly
type
     sz=0..9;
     sy=1..9;
     sd=array [sy,sy] of sz;
     ss=set of sy;

  var
    a:sd;
    x,y:byte;
    i,j:integer;

  procedure ky(a:sd;x,y:byte;var s:ss);------------------eliminating incorrect candidates
    var
       i,j:byte;
  begin
    s:=[1,2,3,4,5,6,7,8,9];
    for i:=1 to 9 do if ix then s:=s-[a[i,y]];
    for i:=1 to 9 do if iy then s:=s-[a[x,i]];
    for i:=1 to 3 do for j:=1 to 3 do
       if ((x-1)div 3*3+ix) and ((y-1)div 3*3+jy)
         then s:=s-[a[(x-1)div 3*3+i,(y-1)div 3*3+j]];
    s:=s-[0];
  end;

  procedure noans;-------------------------------------reacting when contradiction occurs
  begin
    write('No answer!');
    halt;
  end;

  procedure tc;----------------------------------------- place a digit as the value of the cell
    var
       x,y,i,t,n,f:byte;
       s:ss;
  begin
    repeat
       f:=0;
       for x:=1 to 9 do
         for y:=1 to 9 do

                                             26 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

          if a[x,y]=0 then begin
            ky(a,x,y,s);t:=0;if s=[] then noans;
            for i:=1 to 9 do if i in s then begin
               t:=t+1;n:=i;
            end;
            if t=1 then begin a[x,y]:=n;f:=f+1; end;
        end;
    until f=0;
  end;

  function answer:boolean;--------------------solve a puzzle with recursion instructions
    var
       ans:boolean;
       procedure try(x,y:byte);
       var
          i,j,n:byte;
          s:ss;
    begin
       if (y10) then begin
          if a[x,y]0 then if x=9 then try(1,y+1) else try(x+1,y) else begin
              ky(a,x,y,s);if s=[] then exit;
              n:=random(8)+1;
              for j:=n to n+8 do begin
                 i:=j mod 9+1;
                 if i in s then begin
                    a[x,y]:=i;;
                    if x=9 then try(1,y+1) else try(x+1,y);
                    if ans then exit;
                    a[x,y]:=0;
                 end
              end;
          end;
       end else begin
         answer:=true;ans:=true;
       end;
    end;
  begin
    answer:=false;ans:=false;
    try(1,1)
  end;

begin
  randomize;
  assign(output,'shu.txt');rewrite(output);

                                          27 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

  fillchar(a,sizeof(a),0);
  tc;
  if not answer then noans;
  for i:=1 to 9 do begin
      for j:=1 to 9 do write(a[i,j]);
      writeln;
  end;
  close(output);close(input);
end.

2.Creating a puzzle at the level of “easy”
var
   pd:array[1..9]                                                                   of
string=('2347','1358','1269','1567','2468','3549','1489','7952','7863');
   a,a1:array[1..81]of char;
   i:char;
   j,code,i0,k,k1:integer;
   l:string;
   gong2:array[1..9,1..9]of integer=((1,2,3,10,11,12,19,20,21),
      (4,5,6,13,14,15,22,23,24),
      (7,8,9,16,17,18,25,26,27),
      (28,29,30,37,38,39,46,47,48),
      (31,32,33,40,41,42,49,50,51),
      (34,35,36,43,44,45,52,53,54),
      (55,56,57,64,65,66,73,74,75),
      (58,59,60,67,68,69,76,77,78),
      (61,62,63,70,71,72,79,80,81));

function find(number:char;square:integer):integer;---place a certain digit in a certain
region
var
  i,j:integer;
begin
  for i:=1 to 9 do
      if a[gong2[square,i]]=number then begin find:=gong2[square,i];break;end;
end;

begin
  assign(input,'shu.txt');reset(input);
  assign(output,'easy.txt');rewrite(output);
  for j:=1 to 81 do

                                           28 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

     if j mod 9=0 then readln(a[j])
     else read(a[j]);
     a1:=a;
  for i:='1' to '9' do begin
     l:='123456789';
     while l'' do begin
         j:=random(length(l));inc(j);val(l[j],k1,code); delete( l,j,1);
         FOR k:=1 to 4 do
             if pos(pd[j,k],l)>0 then delete(l,pos(pd[j,k],l),1);
         a1[find(i,k1)]:='0';
     end; end;
     j:=random(26);
     for i0:=1 to j do begin
         repeat
             k:=random(80);inc(k);
         until a1[k]='0';
         a1[k]:=a[k];
     end;
     for j:=1 to 81 do
         if j mod 9=0 then writeln(a1[j])
         else write(a1[j]);
     close(input); close(output);
end.

3. Creating a Sudoku at the level of “medium”
It is composed with a counter (see in appendix P.34). The appearance of the digit
1 means this way of blanking out cells is correct. (1 refers to the number of
possible solutions of the puzzle created. If it turns out to be 1, then the puzzle we
create is an eligible puzzle.)
Continue carrying the following pas. files (medium and counter) until counter
turns out to be 1. Then, the output of medium would be the puzzle
type
   po=array['1'..'9']of integer;
var
   a,a1:array[1..81] of char;
   s:array[1..81]of string;
   b:array[1..81]of integer;
   ch:char;
   lie:array[1..81]of byte=(1,2,3,4,5,6,7,8,9,
   1,2,3,4,5,6,7,8,9,
   1,2,3,4,5,6,7,8,9,
   1,2,3,4,5,6,7,8,9,

                                            29 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

  1,2,3,4,5,6,7,8,9,
  1,2,3,4,5,6,7,8,9,
  1,2,3,4,5,6,7,8,9,
  1,2,3,4,5,6,7,8,9,
  1,2,3,4,5,6,7,8,9);
  hang:array[1..81]of byte=(1,1,1,1,1,1,1,1,1,
  2,2,2,2,2,2,2,2,2,
  3,3,3,3,3,3,3,3,3,
  4,4,4,4,4,4,4,4,4,
  5,5,5,5,5,5,5,5,5,
  6,6,6,6,6,6,6,6,6,
  7,7,7,7,7,7,7,7,7,
  8,8,8,8,8,8,8,8,8,
  9,9,9,9,9,9,9,9,9);
   gong:array[1..81]of byte=(1,1,1,2,2,2,3,3,3,
  1,1,1,2,2,2,3,3,3,
  1,1,1,2,2,2,3,3,3,
  4,4,4,5,5,5,6,6,6,
  4,4,4,5,5,5,6,6,6,
  4,4,4,5,5,5,6,6,6,
  7,7,7,8,8,8,9,9,9,
  7,7,7,8,8,8,9,9,9,
  7,7,7,8,8,8,9,9,9);

  c:array[0..16]of byte=(8,7,8,9,6,3,2,1,4,5,4,1,2,3,6,9,8);
  i,j,k,v,m,t,x,cal,xx:integer;
  gong2:array[1..9,1..9]of integer=((1,2,3,10,11,12,19,20,21),
      (4,5,6,13,14,15,22,23,24),
      (7,8,9,16,17,18,25,26,27),
      (28,29,30,37,38,39,46,47,48),
      (31,32,33,40,41,42,49,50,51),
      (34,35,36,43,44,45,52,53,54),
      (55,56,57,64,65,66,73,74,75),
      (58,59,60,67,68,69,76,77,78),
      (61,62,63,70,71,72,79,80,81));
  s0:set of '1'..'9';
  s1:array['1'..'9']of integer;
 function ch1:boolean;--------------------------------------------- --analysis of the array s1
var
  i,j:char;
begin
  ch1:=true;
  for i:='1'to'9'do if (s1[i]>0)and(s1[i]
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

function check:boolean;---------------Distinguish ensuring digits from remaining digits
var
  i,j:integer;
begin
  check:=true;
  for i:=1 to 81 do
      if b[i]=0 then begin check:=false;break;end;
end;

function find(number:char;square:integer):integer;
var
  i,j:integer;
begin
  for i:=1 to 9 do
      if a[gong2[square,i]]=number then begin find:=gong2[square,i];break;end;
end;

procedure solve(number:integer);
var
  i,j,q:integer;
begin
  for i:=1+(hang[number]-1)*9 to 9+(hang[number]-1)*9 do
      if s[i]'' then delete(s[i],pos(a[number],s[i]),1);
  q:=number mod 9;if q=0 then q:=9;
  for i:=0 TO 8 DO
      IF s[q+i*9]'' then delete(s[q+i*9],pos(a[number],s[q+i*9]),1);
  for i:=1 to 9 do
      if                         s[gong2[gong[number],i]]''                      then
delete(s[gong2[gong[number],i]],pos(a[number],s[gong2[gong[number],i]]),1);
end;

procedure doing(va:integer);
var
  i,j:integer;
begin
  for i:=1 to length(s[va]) do
      if not(s[va,i] in s0) then begin s0:=s0+[s[va,i]];s1[s[va,i]]:=va; end
      else begin s1[s[va,i]]:=0;if ch1 then break;end;
end;

begin
 assign(input,'shu.txt');reset(input);
 assign(output,'medium.txt');rewrite(output);

                                           31 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

 //writeln;
 for i:=1 to 81 do
      if i mod 9=0 then readln(a[i])
      else read(a[i]);
   for i:=1 to 81 do s[i]:='123456789';
 x:=random(9);inc(x);
   x:=gong2[4,x];
   m:=1;
   t:=find(a[x],c[m]);
   for i:=1 to 9 do
      if (lie[x]=lie[gong2[c[m],i]])and(hang[t]=hang[gong2[c[m],i]])
          then begin
             x:=gong2[c[m],i];
             b[x]:=1;
             s[x]:='';
             solve(x);
             break;
          end;
   while (cal
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                 if b[x]=0 then b[x]:=1
                 else if b[x]=1 then inc(cal);
                 solve(x);
                 break;
              end;
       end; end;
       for i:=1 to 9 do begin
          s0:=[];
          for ch:='1' to '9' do s1[ch]:=100;
          for j:=1+(i-1)*9 to 9+(i-1)*9 do doing(j);
          for ch:='1' to '9' do if(s1[ch]>0)and(s1[ch]0)and(s1[ch]0)and(s1[ch]
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                x,y:integer;
                llink:point;
                rlink:point;
            end;
var p,q,r,head:point;
       sudoku:array[0..8,0..8] of char;
       i,j:integer; n:integer; c:char;
       can:boolean;
procedure add(x,y:integer);---------------------------------adding two numbers to a chain
 begin
     new(q);
     q^.llink:=r;q^.x:=x;q^.y:=y;q^.rlink:=nil;r^.rlink:=q;
     r:=q;
 end;
function
judge(c:char):boolean;-----------------------------------------------------------------judgment
var i,j:integer; k,l:integer;
Begin
 judge:=true;
 i:=p^.x div 3*3;
 j:=p^.y div 3*3;
 for k:=i to (i+2) do             for l:=j to (j+2) do
   if (k p^.x) and (lp^.y) then
     if (sudoku[k,l]=c) then
         begin
            judge:=false;
            exit;
         end;
 for k:=0 to 8 do
   begin
     if (sudoku[p^.x,k]=c) and (kp^.y) then
                                                       begin
                                                       judge:=false;
                                                       exit;
                                                       end;
     if (sudoku[k,p^.y]=c) and (kp^.x) then
                                                       begin
                                                        judge:=false;
                                                        exit;
                                                       end;
   end;
end;
Begin
assign(input,'medium.txt');reset(input);

                                             34 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

assign(output,'conter.txt');rewrite(output);
new(r);
r^.llink:=nil;
head:=r;n:=0;
for i:=0 to 8 do
 begin
 for j:=0 to 8 do
   begin
     read(sudoku[i,j]);
     if (sudoku[i,j]='0') then add(i,j);
   end;
 readln;
 end;
p:=head^.rlink;
while (p^.llinknil) do
   begin
     if (p^.rlink=nil) and (sudoku[p^.x,p^.y]'0') then
         begin
           inc(n);
           {writeln('result number:',n);
           for i:=0 to 8 do
            begin
              for j:=0 to 8 do
               write(sudoku[i,j]);
              writeln;
            end; }
     sudoku[p^.x,p^.y]:='0';
     p:=p^.llink;
     end;
   can:=false;
     for c:=chr(ord(sudoku[p^.x,p^.y])+1) to '9' do
       if judge(c) then begin
                                can:=true;
                                sudoku[p^.x,p^.y]:=c;
                                if p^.rlink  nil then p:=p^.rlink;
                                break;
                                end;
       if (not can) then begin
                        sudoku[p^.x,p^.y]:='0';
                        p:=p^.llink;
                              end;
end;{while}
writeln(n);
close(input);close(output);

                                              35 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

end.

5.Transformation
(It can change the permutation of digits while the nature remains with the order
file a1.in read in,)
var
   a:array[1..9]of string=('123456789','456789123',
                           '789123456', '231564897',
                            '564897231','897231564',
                             '312645978', '645978312',
                             '978312645');
   a0:array[1..9]of integer;
   ch:array[1..2]of char;
   i,j,x1,x2,x3,x4,x5,k,n,k1,k2,i1,r,flag,m,i0:integer; c1,c2:char; d,s:string;

procedure ssz;-------------------------------------------rotate at an angle of 90   clockwise
var
  b:array[1..9]of string;
  i,j:integer;
begin
  for i:=1 to 9 do b[i]:='              ';
  for i:=1 to 9 do
      for j:=1 to 9 do
         b[j,9-i+1]:=a[i,j];
  a:=b;
end;

procedure hang(x,y:integer);-----------------------------------Rows-in-a-band exchanging
var s:string;i,j:integer;
begin
  s:=a[x];a[x]:=a[y];a[y]:=s;
end;
procedure lie(x,y:integer);-------------------------------Columns-in-a-column exchanging
var c:char;i,j:integer;
begin
  for i:=1 to 9 do begin
     c:=a[i,x];a[i,x]:=a[i,y];a[i,y]:=c; end;
end;

procedure shu(x,y:char);---------------------------------------------------- Digit exchanging
var i,v,w,j:integer;c:char;
begin
  for i:=1 to 9 do begin

                                             36 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

  v:=pos(x,a[i]);w:=pos(y,a[i]);
  a[i,v]:=y;a[i,w]:=x;
end;end;

begin
  assign(input,'a1.in');reset(input);
  assign(output,'a.txt');rewrite(output);
  readln(n,m);
  for i:=1 to n do begin
     readln(d);
     readln(x1,x2);
      if d='hang' then begin
         flag:=random(2);
         if ((flag=1)or(n-i+1=m))and(m0) then begin
            hang(x1,x2);dec(m);
            writeln('task ',i,' ',d,' ',x1,' ',x2,' ');
            for i0:=1 to 9 do writeln(a[i0]) ;writeln; end;end;

      if d='lie' then begin
          flag:=random(2);
        if ((flag=1)or(n-i+1=m))and(m0) then begin
          lie(x1,x2); dec(m);
          writeln('task ',i,' ',d,' ',x1,' ',x2,' ');
              for i0:=1 to 9 do writeln(a[i0]) ;writeln;end;end;
            //else writeln('task',i,' fail');

      if d='shu' then begin
         flag:=random(2);
         if ((flag=1)or(n-i+1=m))and(m0) then begin
         str(x1,s);c1:=s[1];str(x2,s);c2:=s[1];
         shu(c1,c2); dec(m);
         writeln('task ',i,' ',d,' ',x1,' ',x2,' ');
         for i0:=1 to 9 do writeln(a[i0]) ;writeln; end; end;

      if d='ssz' then begin
          flag:=random(2);
        if ((flag=1)or(n-i+1=m))and(m0) then begin
          ssz;dec(m);
          writeln('task ',i,' ',d,' ',x1,' ',x2,' ');
          for i0:=1 to 9 do writeln(a[i0]) ;writeln; end;end;
               end;
     writeln('last');
          for i:=1 to 9 do writeln(a[i]) ;writeln;
  close(output);close(input);

                                            37 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

end.

ii.    Rest pictures showing the process of deducing
                                   38 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                    39 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                    40 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                    41 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                    42 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                    43 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                    44 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

                    45 / 46
2010 S.-T. YAU HIGH SCHOOL MATHEMATICS AWARDS

Team Profile:
We have attended 2010MCM (Mathematical Contest in Modeling) and were designated as
Honorable Mention. In 2009HiMCM (High School Mathematical Contest in Modeling), we
were designated as Meritorious. Our team has a rich experience on applied mathematics and
mathematical model.

                                          46 / 46
You can also read