Question: Question 1 (20 points): Purpose: To write a program using basic Python tools. Degree of Difficulty: Moderate. Restrictions: This question is homework assigned to students
Question 1 (20 points): Purpose: To write a program using basic Python tools. Degree of Difficulty: Moderate. Restrictions: This question is homework assigned to students and will be graded. This question shall not be distributed to any person except by the instructors of CMPT 145. Solutions will be made available to students registered in CMPT 145 after the due date. There is no educational or pedagogical reason for experts outside the CMPT 145 instructional team to provide solutions to this question to a student registered in the course. Students who solicit such solutions are committing an act of Academic Misconduct, according to the University of Saskatchewan Policy on Academic Misconduct. A sudoku is a popular puzzle that involves using the digits from 1 to 9 in various ways. For this assignment, we will consider only what we call a simplified sudoku. A simplified sudoku consists of an N N grid, where N is always a multiple of 3. Each 3x3 block of the grid forms its own area. For example, on a 9x9 grid, there will be 9 such areas:


Question 1 (20 points): Purpose: To write a program using basic Python tools. Degree of Difficulty: Moderate. Restrictions: This question is homework assigned to students and will be graded. This question shall not be distributed to any person except by the instructors of CMPT 145. Solutions will be made available to students registered in CMPT 145 after the due date. There is no educational or pedagogical reason for tutors or experts outside the CMPT 145 instructional team to provide solutions to this question to a student registered in the course. Students who solicit such solutions are committing an act of Academic Misconduct, according to the University of Saskatchewan Policy on Academic Misconduct. A sudoku is a popular puzzle that involves using the digits from 1 to 9 in various ways. For this assignment, we will consider only what we call a simplified sudoku. A simplified sudoku consists of an Nx N grid, where N is always a multiple of 3. Each 3x3 block of the grid forms its own area. For example, on a 9x9 grid, there will be 9 such areas: 1 3 3 2 9 07 5 6 4 | s 4 5 6 7 5 8 8 9 2 7 1 8 7 13 00W 000 1 w ON UT st loom 00 + 4 5 OOOO 5 00W 00 2 1 5 2 4 1 7 6 7 9 2 6 8 7 4 1 3 8 9 8 0 HON HON 8 3 2 3 1 6 7 00 N 4 5 6 4 8 6 o| 9 4 = 7 1 9 9 5 7 2 1 A simplified sudoku is valid if and only if each area contains all of the digits from 1 to 9 exactly once (real sudokus have constraints on the rows and columns as well, but we'll ignore those here). The example above is a valid simplified sudoku. In this question you will implement a program that checks whether an N * N square of numbers is a valid simplified sudoku or not. Input The data for your program will come from a datafile that describes a single sudoku puzzle that may or may not be valid. You can 'hardcode' the name of the data file in your program. To test on different data files, just change the file name in your program. The file will consist of the following lines: A number N on a line by itself. This will be the size of the sudoku. You may assume that N is greater than 0 and is always a multiple of 3. N lines of N of integers, separated by spaces A sample input file might look like this: 3 1 1 1 2 2 2 3 3 3 You will be provided with several input files on the class Canvas. You can test your program with these. We will also test your program with some input files that we are NOT giving you. Output For the candidate sudoku in the file, your program should simply print: True if the sudoku is valid (i.e. each digit is used once in each 3x3 area) False otherwise What to Hand In Your implementation of the program: alqi.py. Be sure to include your name, NSID, student number, course number and section number at the top of all documents. Evaluation 4 marks: Your program reads the datafiles correctly 8 marks: Your validity check is well implemented and can handle sudokus of varying size 4 marks: Your program produces the correct output for each test file 4 marks: Documentation. You have made an appropriate effort to document your code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
