I would love to, but my hard drive in my ThinkPad just died. I was having issues with is since the summer, and it can no longer be written to, so win2k wont let me log in.
The algorithm to solve that number challenge problem is like so
Code:
Read In the text file to a 2d array
Create 3d array with the format [row][col][possiblities]
It will be bool IsPossible[16][16][16] each space in 2d matrix has 1-16 has possible values
START
Set all the possiblites to false
for i=0 ; i<rows ; i++
for j=0 ; j<cols ; j++
if space is open ie==17 in the text file
for p=1; p<= 16 ; p++
if IsValid(i,j,p) see below for IsValid pseudocode
set IsPossible[i][j][p] to true
for all spots that have only 1 possiblity set those to correct value
go back to START unless board is filled
bool IsValid(i,j,p)
Current 4x4 square starts at ( 4 * (i/4) ),(4*(j/4))
remember the fun integer math :) so that rounds to the next lowest multiple of 4
if [i][j] is on the lead diagonal (ie [1][1] [2][2] [MAX][MAX] )
Then it is only possible if the number p doesnt appear in the row i, col j, the lead diagonal, or the current 4x4 square.
else if [i][j] is on the back diagonal (ie [0][MAX] [1][MAX-1] [2][MAX-2] )
Then it is only possible if the number p doesnt appear in the row i, col j, the back diagonal, or the current 4x4 square.
else
p is only possible if p does not already appear in row i or col j or the 4x4 square
I made the 2d array that represented the board global, and wrote a bunch of functions to check if p was in a given row or col or diag or 4x4
ex
bool IsInRow(int r,int p);
bool IsInCol(int c,int p);
bool IsInLead(int r,int c,int p );
bool IsInBack(int r,int c,int p);
bool IsIn4x4(int r,int c, int p)