![]() It should check whether putting the number into the (row, col) square of the puzzle is legal or not. ![]() The prototype of this method should be public static boolean isPlacementOK(int puzzle, int row, int col, int number) You should write a static method to do the checking. The code used to check the properness of placing a number in a particular location is very useful and may be needed some place else. You need to do this for each number that is supposed to be filled in. Fill in that number if the placement is proper. Remember the constraints along a row, along a column, and within a subregion. Within the loop, you select a random position and a random number and check if placing that number in that location is acceptable. If you are generating the puzzle, you should prompt to find out how many numbers are pre-defined and filled in. If you load the puzzle from file, the method requires the puzzle and the name of the file as arguments. Generating a puzzleįirst of all, you need to define and create a 9 X 9 array. Notice that the generated puzzle may be different from person to person. Remember that file cannot be compiled individually. Remember that multi-line comments are surrounded by /* and */. Preparation Enter some comments at the top of your file listing your name, CS 177, your lab section, and today's date. That is, you should write a program that can generate a random puzzle and display it. To get you started, let's consider a subtask you can do easily in one or two weeks. You have three weeks to complete the project. This project is a bit more involved than the previous two projects. Divide and Conquer - Turning in a Milestone In this project, you can assume all inputs are correct. Initialize the 9 X 9 grid with proper values, 0 for blank To summarize, the major tasks you need to perform are:Īsk the user whether to load a puzzle from file or from auto generation. Your program should also allow users to actually fill in a number or erase a number filled in previously. Users can select one blank position in the puzzle and your program should help by suggesting which numbers may fit in that particular location. Second, your program needs to help users finish the puzzle. You can use random numbers to decide the position of a new number and its value, and you should also check whether the placement is proper. Of course, the puzzle should follow the rules of Sudoku. To generate a puzzle, you need to ask users how many numbers to fill in before creating the puzzle. In the skeleton code, the method to load from file has already been finished and you only need to call that method. Download StdIn.java and copy both files into the working directory where yourįor this project, you have to accomplish two tasks.įirst, you need to load a puzzle from a file or generate one yourself.The files for this project in this directory. Change to the directory created just now using the.You should create a new directory for each project. Create a directory for this project: mkdir proj3.Enter the cd cs177 command to go to your.In your console or terminal window enter theĬd command to ensure that you are in your home.Static methods (section 2.1 pages 184-206).StdIn library (section 1.5 pages 126-131).Two-dimensional arrays (section 1.4 pages 102-107).Shown below is a Sudoku puzzle along with its solution.īefore you start this project, you must understand: Completed puzzles are usually a type of Latin square with an additional constraint on the contents of individual regions. The puzzle setter provides a partially completed grid. The objective is to fill a 9 X 9 grid so that each column, each row, and each of the nine 3 X 3 boxes (also called blocks or regions) contains the digits from 1 to 9 only one time each. Sudoku is a logic-based, combinatorial number-placement puzzle. In this project, you will use your knowledge of arrays, input/output and static methods to implement a simplified Sudoku helper. Divide and Conquer - Turning in a Milestone.Project 3 - Sudoku Helper Project 3: Sudoku Helper Milestone Due Thursday, October 22th, 9:00 pm Final Project Due Thursday, October 29th, 9:00 pmįor this project you will develop a simple helper for Sudoku, which shows the numbers you can fill in any certain blank space and can also generate simple Sudokus.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |