IMPORTANT As work is submitted on-line, the deadline is midnight on the hand in date. Read the marking scheme carefully. This is an individual project and no group work is permitted. Learning Outcomes To develop problem-solving skills To evaluate common data structures To enhance practical programming skills. Assignment Purpose and Overview The purpose of this assignment is to implement a Sudoku (https://en.wikipedia.org/wiki/Sudoku) puzzle solver program. The puzzle can be represented as a 9_ grid as illustrated below XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX9 1 6 As it can be observed,
IMPORTANT As work is submitted on-line, the deadline is midnight on the hand in date. Read the marking scheme carefully. This is an individual project and no group work is permitted. Learning Outcomes To develop problem-solving skills To evaluate common data structures To enhance practical programming skills. Assignment Purpose and Overview The purpose of this assignment is to implement a Sudoku (https://en.wikipedia.org/wiki/Sudoku) puzzle solver program. The puzzle can be represented as a 9_ grid as illustrated below XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX9 1 6 As it can be observed, some numbers are provided while some numbers are missing. The objective is to fill the missing numbers in such a way that the following constraints are met: Row constraint: each row contains all of the numbers from 1 to 9 Column constraint: each column contains all of the numbers from 1 to 9 Block constraint: each of the nine 3_ blocks, which compose the grid, contain all of the numbers from 1 to 9. A well-posed puzzle, such as the one illustrated before, has a single solution. For example, the only solution for the puzzle is illustrated below; the red numbers are the ones that should be discovered by the solver XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX2 8 For the purposes of this assignment, in order to allow the solver to load puzzles, the puzzles will be stored in text files in the format presented below, where: the first number indicates the number of rows of the puzzle the second number indicates the number of columns of the puzzle the remaining 81 numbers, presented as 9 rows of 9 columns each, represent the initially provided puzzle numbers and the missing positions, the latter represented as XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXXThe solver program must investigate if there is a solution to the puzzle, and if there is, it needs to print it to the console, accompanied by the number of steps it required to perform to reach the solution. Overall, in this assignment, you will: Evaluate different data structures for storing Sudoku puzzles and their solutions Implement efficient data structures for storing and manipulating Sudoku puzzles and their solutions Design an algorithm that solves Sudoku puzzles using backtracking Design and implement appropriate data structures for supporting the algorithms backtracking operation Develop a program that implements the algorithm which solves Sudoku puzzles using backtracking Assignment Requirements and Constraints The assignment must start by defining efficient data structuresto load a Sudoku puzzle. To that end, you will define the SudokuPuzzle data structure and will use a function to initialize an instance of the data structure accordingly. In particular, the SudokuPuzzle data structure must be able to preserve the following important information about a Sudoku puzzle: number of rows and columns in the puzzle the Sudoku puzzle numbers in a two-dimensional array the positions of the initially provided puzzle numbers in order to prevent programs from changing them. This must be implemented as a two-dimensional bool array named locked the number of missing numbers in the puzzle the start position for solving the puzzle (i.e., the position of the first 0) the last missing element position of the puzzle (i.e., the position of the last 0) To facilitate our description, the following figure presents an example input file and what needs to be saved according to the above specification: In the above example, the number of missing numbers is 49, the first and last missing numbers are located at positions (0,0) and (8,8) respectively. As soon as the file is loaded, you should print this information on the console in the following format: +—————–+ |0|0|2|0|7|0|1|0|0| |0|4|0|0|0|0|0|7|0| |9|0|1|2|0|4|8|0|5| |0|0|4|0|5|0|7|0|0| |2|6|0|0|0|0|0|1|3| |0|0|7|0|3|0|2|0|0| |1|0|8|9|0|6|5|0|7| |0|2|0|0|0|0|0|9|0| |0|0|9|0|1|0|6|0|0| XXXXXXXXXXNumber of missing numbers: 49 First missing number: (0,0) Last missing number: (8,8) The signature of the loading function must be the following: SudokuPuzzle* loadPuzzle(string filename) A number of puzzles are provided in Appendix 1 for you to test your implementation. Number of rows Two-dimensional array representing a Sudoku Puzzle Number of columns First empty number; the start position of the puzzle Last missing number; the finish position of the puzzle The program should then proceed to solve the puzzle. The algorithm will employ a backtracking approach according to the following high-level concept: Test if a missing number cell can accept a valid number in the range of 1-9 If a valid number has been found, then proceed to the next missing number Otherwise, you have reached a dead end and you need to backtrack To facilitate our description, we provide an example based on the input file described above. The algorithm starts by setting up the missing numbers one by one reaching the following intermediate state: +—————–+ |3|5|2|6|7|8|1|4|9| |6|4|0|0|0|0|0|7|0| |9|0|1|2|0|4|8|0|5| |0|0|4|0|5|0|7|0|0| |2|6|0|0|0|0|0|1|3| |0|0|7|0|3|0|2|0|0| |1|0|8|9|0|6|5|0|7| |0|2|0|0|0|0|0|9|0| |0|0|9|0|1|0|6|0|0| XXXXXXXXXXThe next missing number to be completed is located at position (1,2) and is highlighted with bold red font in the above figure. As it can be calculated, there is no valid number to enter for that missing position, so the program must backtrack to the previous correct state and try a different route. It is compulsory that you implement a Stack data structure to enable the backtracking functionality. The Stack data structure must be designed using generic programming techniques and should implement the following functions: isEmpty: checks if the stack is empty push: inserts an element to the top of the stack pop: removes an element from the top of the stack, if it exists, without returning it top: returns the element located on the top of the stack, if it exists As soon as the program finishes, if a solution is found, you should print this information on the console in the following format: Solution found in 1517 steps! +—————–+ |5|8|2|3|7|9|1|6|4| |6|4|3|1|8|5|9|7|2| |9|7|1|2|6|4|8|3|5| |3|1|4|6|5|2|7|8|9| |2|6|5|8|9|7|4|1|3| |8|9|7|4|3|1|2|5|6| |1|3|8|9|2|6|5|4|7| |7|2|6|5|4|8|3|9|1| |4|5|9|7|1|3|6|2|8| +—————–+
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.