Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python question A sudoku is a popular puzzle that involves using the digits from 1 to 9 in various ways. For this assignment, we will

python question
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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 2 3 2 95 64 4 5 6 4 5 6 9 7 8 7 8 9 1 8 7 2 1 3 4 5 6 5 2 1 5 6 8 1 3 2 4 3 6 9 7 4 7 8 9 9 8 7 2 1 3 8 3 2 3 21 5 6 7 4 5 6 4 8 6 9 4 8 7 1 9 9 5 7 2 1 3 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: 2 2 2 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 (.e. each digit is used once in each 3x3 area) False otherwise 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. 1 (2 marks) Comment on your program's correctness. How confident are you that your program is cor- rect? 2. (2 marks) Comment on your problem-solving process. Did you start with a plan, or a design? Did you implement your code using iterative refinement (CMPT 141), or some other approach? Did you write all your code at once and debug it? 3. (2 marks) How much time did you spend writing your program? Did it take longer or shorter than you expected? If anything surprised you about this task, explain why it surprised you. 3 1 2 3 4 5 6 7 8 9 3 1 2 1 4 5 6 7 8 9 3 1 2 3 4 5 6 7 8 10 8 9 1 1 2 3 3 2 1 1 2 3 2 4 5 6 5 6 4 6 5 4 7 8 9 9 8 7 8 7 9 8 1 2 3 3 2 1 1 2 3 3 4 5 6 5 6 4 6 5 5 7 8 9 9 8 7 8 7 9 1 2 3 3 2 1 1 2 3 4 5 6 5 6 4 6 5 4 7 8 9 9 8 7 8 7 9 9 1 2 3 3 2 1 1 2 3 4 5 6 5 6 4 6 5 4 7 8 9 9 8 7 8 7 9 9 7 1 2 3 3 2 1 1 2 3 4 5 6 5 6 4 6 5 4 54 7 8 9 9 8 7 8 7 9 7 1 2 3 3 2 1 1 2 3 4 5 6 5 6 4 6 5 4 6 54 7 8 9 9 8 7 8 7 9 7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions