![]() (You'll also want to check that each value is a legitimate number: if they give you a blank or a too-high number, you know that the board is not complete.) When you get to the end of the board, you'll know that all the values are correct, and there is no more checking required. As you place numbers in the board, it becomes a O(1) operation to determine whether any values are being duplicated in a given row, column, or square. Simply take the numbers in the order that they appear on the board, and begin building this data structure. Regardless of how your original board is being represented, this can be a simple and very fast way to check it for completeness and correctness. In other words, if you add a 5 to the second row, first column, you would set rows to true, along with columns and squares, to indicate that the row, column, and square now have a 5 value. The array's index represents the value that got placed into that row, column, or square. Create an array of booleans for every row, column, and square.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |