--- /dev/null
+<!--#set var="root_directory" value="../../.." --><!--#include virtual="$root_directory/shared/header.shtml"-->
+
+<h1>Assignment #1</h1>
+<p><em>Due Friday, October 8, 2010</em></p>
+
+<h2>Purpose</h2>
+
+<p>Remind ourselves of the C or C ++ syntax, in particular: arrays,
+loop, conditional, functions, ...</p>
+
+<p>Note: Please identify all your work.</p>
+
+<p>Write a C or C ++ code to
+solve <a href="http://en.wikipedia.org/wiki/Sudoku">sudoku
+puzzles</a>.</p>
+
+<p>Sudoku is a one player board puzzle in which the player fills in
+the empty cells on a 9x9 board with digits 1 to 9. The rules are
+simple:</p>
+
+<ul>
+ <li>The digits 1 to 9 must be on every row with no repetition.</li>
+ <li>The digits 1 to 9 must be on every column with no repetition.</li>
+ <li>The digits 1 to 9 must be on every tile with no repetition.</li>
+</ul>
+
+<p>The <em>tiles</em> in the rules refer to 3x3 sub-regions that cover
+the 9x9 board with no overlap. A game is seeded by having some digits
+1 to 9 placed on the board (satisfying the rules above). The player
+needs to complete the filling the board with digits 1 to 9 while
+respecting the rules above.</p>
+
+<h2>Algorithm — key steps</h2>
+
+<ol>
+ <li>Set the geometry of the board, i.e., the tiles.</li>
+ <li>Read in the starting configuration on the board.</li>
+ <li>Initialize in a trial array all the candidate digits for every
+ unfilled cell, i.e., digits 1 to 9.</li>
+ <li>For an unfilled cell on the board and for one of the digits in
+ the trial array corresponding to this cell, scan the row, column
+ and block for digit repetition.</li>
+ <li>If a repetition is found, eliminate this trial digit.</li>
+ <li>Repeat the two steps above for every unfilled cell on the board
+ and for every digit left in the trial array corresponding to these
+ unfilled cell 1.<li>
+ <li>If at any time the trial array contains only one (1) trial digit
+ for an unfilled cell on the board, this digit is part of the solution
+ of the sudoku puzzle and marked as such.</li>
+ <li>Accumulate the number of events in the steps above. An event
+ could be removing a digit from the trial array or selecting a
+ digit as part of the solution.</li>
+ <li>Repeat the scans above until the number of events is zero (0),
+ i.e., a steady state is reached, at which time the solution of the
+ sudoku puzzle is either obtained or the puzzle is too hard to
+ solve by this simple algorithm.</li>
+</ul>
+
+<h2>I/O</h2>
+
+<p>A simple file interface should prove sufficient to check your
+code. Namely, the initial configuration of digits on the board could
+be typed in a file with an obvious format</p>
+
+<pre>
+- - 1 3 - - - 6 -
+- 5 - - - 1 - - 3
+...
+</pre>
+
+<p>The output of any configuration could follow the same format.</p>
+
+<p>A run would then be</p>
+
+<pre>
+cat initialboard | ./sudoku
+</pre>
+
+<h2>Suggested functions</h2>
+
+<p>Please write a modular code. Functions could be</p>
+
+<dl>
+ <dt><code>geometry()</code></dt>
+ <dd>set the geometry of the board (rows, column, tiles)</dd>
+ <dt><code>read_config()</code></dt>
+ <dd>read in a board configuration</dd>
+ <dt><code>print_config()</code></dt>
+ <dd>print a board configuration</dd>
+ <dt><code>is_forbiden()</code></dt>
+ <dd>check if a trial digit is forbidden in a cell</dd>
+ <dt><code>check_cell()</code></dt>
+ <dd>finds and removes forbidden digits in a cell</dd>
+ <dt><code>check_all_cells()</code></dt>
+ <dd>scans over all cells to remove forbidden trial digits</dd>
+</dl>
+
+<h2>Sample puzzles</h2>
+
+<pre>
+5 3 - - 7 - - - -
+6 - - 1 9 5 - - -
+- 9 8 - - - - 6 -
+
+8 - - - 6 - - - 3
+4 - - 8 - 3 - - 1
+7 - - - 2 - - - 6
+
+- 6 - - - - 2 8 -
+- - - 4 1 9 - - 5
+- - - - 8 - - 7 9
+</pre>
+
+<pre>
+5 3 4 6 7 8 9 1 2
+6 7 2 1 9 5 3 4 8
+1 9 8 3 4 2 5 6 7
+
+8 5 9 7 6 1 4 2 3
+4 2 6 8 5 3 7 9 1
+7 1 3 9 2 4 8 5 6
+
+9 6 1 5 3 7 2 8 4
+2 8 7 4 1 9 6 3 5
+3 4 5 2 8 6 1 7 9
+</pre>
+
+<ul>
+ <li><a href="1.cfg">1.cfg</a></li>
+ <li><a href="2.cfg">2.cfg</a></li>
+ <li><a href="3.cfg">3.cfg</a></li>
+</ul>
+
+<!--#include virtual="$root_directory/shared/footer.shtml"-->