# 算法代写 | Coursework Assignment: Sudoku assignment

The 9 tasks in this assignment make up the Sudoku coursework assignment. The tasks in this assignment consist,
in the main, of functions or lines of code to be written in pseudocode. Because your solutions should be written in
pseudocode, marks will not be deducted for small syntax errors as long as the pseudocode can be understood by
a human. Having said that, it is highly recommended that you use the pseudocode conventions given in this module.
There are 50 marks available in total for this assignment

Background: Sudoku and Pseudoku

A Sudoku puzzle consists of 9-by-9 grid of squares, some of them blank, some of them having integers from 1 to 9.
A typical Sudoku puzzle will then look something like this:
To solve this puzzle, all the squares must be ﬁlled with numbers from 1 to 9 such that the following are satisﬁed:
1. every row has all integers from 1 to 9 (with each appearing only once)

2. every column has all integers from 1 to 9 (with each appearing only once)

3. every 3-by-3 sub-grid, or block (with bold outlines around them going from top-left to bottom-right) has all
integers from 1 to 9

In this coursework, we won’t be generating and solving Sudoku puzzles exactly, but a simpliﬁed version of Sudoku
puzzles, which I will call Pseudoku puzzles – pronounced the same. In a Pseudoku puzzle, we now have a 4-by-4
grid of squares, some of them blank, some of them having integers from 1 to 4. A typical Pseudoku puzzle will look
like this:

Now to solve this puzzle, all the squares must be ﬁlled with numbers from 1 to 4 such that the following are satisﬁed:
1. every row has all integers from 1 to 4 (with each appearing only once)

2. every column has all integers from 1 to 4 (with each appearing only once)

3. every 2-by-2 sub-grid, or block (with bold outlines around them going from top-left to bottom-right) has all
integers from 1 to 4

These three conditions will be called the Pseudoku conditions. For the above Pseudoku puzzle, a solution is:
The goal of the whole Sudoku assignment is to produce an algorithm that can generate Pseudoku puzzles. It is
important to emphasise that a Pseudoku puzzle is speciﬁcally a 4-by-4 puzzle as above, and not 9-by-9, or any other
size. So when we refer to Pseudoku puzzles, we are speciﬁcally thinking of these 4-by-4 puzzles.

Generating Pseudoku puzzles

You are going to produce an algorithm that generates a Pseudoku puzzle. This algorithm starts with a vector of
four elements, with all the integers 1 to 4 in any particular order, e.g. 1,2,3,4 or 4,1,3,2. In addition to this vector,
the algorithm also starts with an integer n, which is going to be the number of blank spaces in the generated puzzle.
This whole process will be more modular, i.e. the algorithm will combine multiple, smaller algorithms.

The big picture of the algorithm is to construct a solved Pseudoku puzzle by duplicating the input vector
mentioned earlier. Then from the solved puzzle, the algorithm will remove numbers and replace them with blank
entries to give an unsolved puzzle. These are the main steps in the algorithm:

1. Get the input vector called row and number n

2. Create a vector of four elements called puzzle, where each element of puzzle is itself the vector row

3. Cyclically permute the elements in each element of puzzle so that puzzle satisﬁes the Pseudoku conditions

4. Remove elements in each element of puzzle to leave blank spaces, and complete the puzzle E-mail: itcsdx@outlook.com  微信:itcsdx 