Task: Implement a console program that can generate Sudoku games and solve Sudoku problems.
1、GitHub:https://github.com/MiaoZhou48/SoftwareEngineeringProject
2. Time consumption
PSD2.1
|
Personnal Software Process Stages | Estimated time (minutes) | Actual time (minutes) |
Planning | plan | 40 | 40 |
.Estimate | . Estimate how long this task will take | ||
Development | develop | 150 | 120 |
.Analysis | .Requirements analysis (including learning new technologies) | 180 | 200 |
.Design Spec | .Generate design documentation | 150 | 150 |
.Design Review | .Design review (review design documents with colleagues) | 60 | 60 |
.Coding Standard | .Code Specifications (to develop appropriate specifications for current development) | 60 | 60 |
.Design | specific design | 80 | 80 |
.Coding | .Specific code | 1600 | 1800 |
.Code Review | .code review | 100 | 150 |
.Test | .testing (self-testing, modifying code, committing modifications) | 200 | 250 |
Reporting | Report | 120 | 150 |
.Test Report | .testing report | 80 | 100 |
.Size Measurement | . Computational workload | 40 | 30 |
.Postmortem & Process Improvement Plan | .Summary after the fact and propose a process improvement plan | 50 | 40 |
total | 2910 | 3190 |
3. Problem solving ideas:
This project can be subdivided into two functions: generating Sudoku and solving Sudoku.
To generate Sudoku, I consider the method of backtracking, and continuously solve the incomplete Sudoku, so as to obtain the corresponding number of perfect Sudoku.
After the method is determined, it is a long road of learning. I refer to the blog of the corresponding backtracking algorithm and the blog of Sudoku generation of other algorithms.
In the process of learning, I also saw a lot of new ideas to generate Sudoku, such as transforming a reasonable Sudoku, and then judging whether it still conforms to the Sudoku specification after the transformation. To generate Sudoku in this way, firstly, the mutuality of the results is guaranteed, and secondly, compared with backtracking, it does not require a lot of calculations, which saves a lot of time.
However, since it has already been written with the backtracking algorithm, I will try again and dare to change my thinking in the subsequent improvement stage.
4. Design and implementation process
The main body of the program is 3 functions
judge(): This function is used to judge the backtracking conditions in the Sudoku solving function.
solve(): The specific solution function body.
construct(): Construct function.
Encapsulation into functions facilitates code reuse, and at the same time improves program simplicity and readability.
Function logic description:
5. Performance improvement and ideas
6. Code description (idea explanation + comment description)
7. Actual time
The specific time consumption is shown in the table at the top.