0% found this document useful (0 votes)
55 views1 page

HW 06

Your homework assignment is to write a recursive program to solve a Sudoku puzzle by trying all possibilities for each empty square using a brute force approach and testing if the partial solution remains legal after each choice before moving on to the next square. The instructor provides a display function and recommends including a checkLegal function that can check any row, column or 3x3 subsquare to simplify testing legality regardless of the part of the board being checked. The program should implement a standard 9x9 Sudoku board broken into 3x3 blocks and can represent the magic numbers as actual numbers rather than symbols.

Uploaded by

api-315434555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

HW 06

Your homework assignment is to write a recursive program to solve a Sudoku puzzle by trying all possibilities for each empty square using a brute force approach and testing if the partial solution remains legal after each choice before moving on to the next square. The instructor provides a display function and recommends including a checkLegal function that can check any row, column or 3x3 subsquare to simplify testing legality regardless of the part of the board being checked. The program should implement a standard 9x9 Sudoku board broken into 3x3 blocks and can represent the magic numbers as actual numbers rather than symbols.

Uploaded by

api-315434555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Homework Assignment 6

Your assignment is to write a recursive program to solve a Sudoku puzzle.


To simplify things a little bit, I have provided for you a display function.
You dont have to do that part yourself. (And my testing code will have the
same displays for all students.)
You dont have to actually play the game. You can do this with brute
force. That is, for an empty square, you may run a loop on all possibilities,
set the square for the current possibility, and then test whether the board
remains legal for that choice. If so, then recursively try the next open square.
I highly recommend that your test for legality include a function such as
checkLegal(minRow, maxRow, minCol, maxCol)
that will allow you to write one function for checking, regardless of whether
you are checking a single row, a single column, or 3 3 subsquare.
YOU ARE PERMITTED to write this as a standard Sudoku puzzle,
that is, of nine rows and columns broken into three blocks of three going
across and going down. You are still required to label the magic numbers
(like 3 or 9) as symbols rather than as numbers, but you can in fact write
the code for three and for nine.

You might also like