SCI1022-无代写-assignment 4
时间:2023-06-01
MATLAB for SCI1022 assignment 4: Solving Sudoku
This assignment contributes 20% of your final mark for the MATLAB module. To complete the
assignment, write a MATLAB live-script or normal script, and provide a pdf-file with your
results including the figures. Each task needs to be clearly coded in the script, with each task
beginning a separate block within the code.
In this assignment you are solving Sudoku puzzles, using data and functions we used in the
lab classes, and a new function to solve any Sudoku puzzle.
1. Task: Solve Sudoku
Try to solve all 17 puzzles of the data file “sudoku.examples.mat”. Note, that the
puzzles are sorted, with the first the easiest and the last the hardest (see variable lvl,
for the difficulty level of each puzzle). Start your code based on the functions
sudoku_notes0 and sudoku_method_1.
• Present two example solutions for two different Sudoku puzzles.
• Clearly state which puzzles your solution can solve or not solve.
• Explain how your method of solving Sudoku puzzles works.
For solving the first 8 puzzles you will get 3 points. If your code can solve at least one
additional puzzle you will get 4 points.
(4 points)
Notes:
• For this task you are not allowed to use the function sudoku_mathworks or
any code derived from it.
• Your code must follow an algorithm, but not just explicitly provide the solution
for each puzzle hard coded (e.g., if puzzle #8, then solution = xyz).
• Solving all puzzles is very difficult. Try to just improve the current code a little
bit. Even this may be a bit of a coding challenge.
• Using the given functions, you will be able to solve the first 8 puzzles.
• Check the quizzes and worksheets for ideas on how to solve at least one of the
other puzzles.
2. Task: Solve Sudoku #16 and #17
Solve the Sudoku puzzles #16 and #17 using the function sudoku_mathworks.
(2 points)
3. Task: Number of function calls
The function sudoku_mathworks uses a recursive function approach.
• Which line of the codes shows that this code is a recursive function?
• For the puzzles #1, #9, #13 and #17: How many times is the function
sudoku_mathworks called to solve these puzzles?
(2 points)
4. Task: Explain the method sudoku_mathworks
Explain how the function sudoku_mathworks works. What approach is this method
using?
Hint: The function includes the function candidates, which is similar to the function
sudoku_notes0.
(2 points)
essay、essay代写