244: GRIDS

Programs that do not have headers and documentation as outlined here will receive a PENALTY. This is not that hard.
Many people's last programs were nice but... when I see the following things before I even execute code, I have an unfavorable impression from the start: In short: lack of attention to detail and effort.
Finally: Do your own work!

GRIDS: Creating Latin Squares & Sudoku Grids with 2d Arrays

0. Come to class as there may be corrections, changes and additions.   Significant late penalty.
1. Using Visual C# Express, create a C# Console Program OR a C# Windows Program
2. Follow these directions to SUBMIT a folder called "GRID1" to your class account
3. Comment! (guidelines)
4. Either program should use my PRINT LIBRARY. (download & unzip; two files in 'dll Library' folder - look at ReadMe.txt)
5. Review the HONESTY policy. Document sources both inanimate and animate!.

Create Code that will allow user to: 1. create & a random grid (1-9). print using my library. 2. create & a rows/no repetitions grid. print using my library. break 3. create & a latin square. print using my library. [4. create & a sudoku. print using my library.] Menu / Buttons should allow choice & exit.

Each of the following tasks should be a method [in a library if you do both console and windows] with the 2-d array being passed as a parameter. Use MY PrintLibrary dll. The program should create a series of 9x9 matrices as follows:

1. RandomGrid(): Fill in rows/cols randomly (1-9) and Print matrix (method: PrintGrid) 30% if you only get this working correctly 4 4 8 | 7 9 7 | 3 3 2 2 5 7 | 5 3 9 | 3 7 3 6 6 5 | 5 8 4 | 6 5 8 ------+-------+------ 5 6 4 | 5 6 6 | 1 3 6 9 8 6 | 4 9 9 | 9 5 7 7 9 7 | 1 2 6 | 4 4 2 ------+-------+------ 9 6 4 | 9 8 2 | 4 1 1 8 1 5 | 5 2 8 | 1 7 6 1 8 1 | 6 7 3 | 7 1 1 random grid: NO CHECK for repetitions...

2. RowsGrid(): Fill in rows so each row has no duplicates & print matrix Rows ONLY... |2|3|1|4|5|6|9|8|X| ^ Must use a nested loop control structure that randomly generates a candidate number and compares it with all previous numbers in that row until it finds one that will fit. It will ALWAYS find a value that will fit eventually. 60% if you only get this working correctly 4 6 1 | 9 5 3 | 8 2 7 5 6 8 | 3 1 2 | 7 4 9 1 8 9 | 3 6 4 | 2 5 7 --------------------- 4 9 6 | 2 1 3 | 5 8 7 6 4 5 | 9 1 3 | 8 2 7 7 4 8 | 6 9 3 | 2 5 1 --------------------- 7 8 5 | 2 1 4 | 3 9 6 7 5 2 | 4 8 9 | 3 6 1 7 9 1 | 8 4 2 | 5 3 6 Grid with NO repetitions in ROWS ... 242 rows generated to get 9 valid rows CONSOLE EXAMPLE: ================
spring break
3. LatinSquare(): Fill in rows & columns so there's no duplicates & print matrix Rows AND Columns... 95% if you only get this working correctly |1|2|3|4|5|6|7|8|9| |2|3|4|5|6|7|8|9|1| |3|4|5|6|7|8|9|2|X| There is NO X that will fit! SO?? ... Must use a nested loop control structure that randomly generates a candidate number and compares it with all previous numbers in that row AND column until it finds one that will fit. It will NOT ALWAYS find a value that will fit. THEN WHAT? 9 8 4 | 1 3 5 | 7 2 6 4 2 9 | 7 8 6 | 1 3 5 6 4 7 | 8 1 9 | 2 5 3 --------------------- 2 6 5 | 4 9 8 | 3 7 1 5 7 1 | 3 2 4 | 9 6 8 7 1 2 | 5 6 3 | 4 8 9 --------------------- 3 9 6 | 2 5 1 | 8 4 7 1 3 8 | 6 4 7 | 5 9 2 8 5 3 | 9 7 2 | 6 1 4 Grid with NO repetitions in ROWS OR COLS ... 2405 grids attempted before a valid one was found

FULL CREDIT (part 2 - after break): 4. Sudoku(): Fill in sudoku (no dups in 3x3 grids or row/col) & print matrix 105% if you get this working correctly and explain to me 8 3 1 | 9 6 2 | 5 4 7 7 5 4 | 8 1 3 | 9 2 6 9 6 2 | 7 5 4 | 1 8 3 --------------------- 5 1 7 | 4 9 8 | 6 3 2 4 2 9 | 6 3 1 | 7 5 8 3 8 6 | 5 2 7 | 4 1 9 --------------------- 1 9 5 | 2 8 6 | 3 7 4 2 4 3 | 1 7 9 | 8 6 5 6 7 8 | 3 4 5 | 2 9 1 Grid with NO repetitions in ROWS OR COLS OR GRIDS ... 148 grids attempted before a valid one was found "The number of valid Sudoku solution grids for the standard 9x9 grid was calculated by Bertram Felgenhauer and Frazer Jarvis in 2005 to be 6,670,903,752,021,072,936,960." [Mathematics of Sudoku - Wikipedia] You may use additional meta-structures to help determine puzzle, but cannot use predetermined grids or patterns. You must capture the randomness implied above...