function sudoku_test10 ( )

%*****************************************************************************80
%
%% sudoku_test10() tests sudoku_check().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 October 2007
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sudoku_test10():\n' );
  fprintf ( 1, '  sudoku_check() checks that a Sudoku is legal;\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Errors have the form KIJ\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  0IJ means that A(I,J) is an illegal digit;\n' );
  fprintf ( 1, '  1IJ means A(I,J) repeats a value in row I;\n' );
  fprintf ( 1, '  2IJ means A(I,J) repeats a value in column J;\n' );
  fprintf ( 1, '  3IJ means A(I,J) repeats a value in its "box";\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  0 means no violations were discovered;\n' );

  s = [ ...
       3,4,1,9,2,7,5,6,8; ...
       6,9,2,1,8,5,7,3,4; ...
       8,5,7,4,6,3,1,9,2; ...
       1,3,4,2,9,6,8,7,5; ...
       2,7,8,5,3,4,6,1,9; ...
       5,6,9,7,1,8,4,2,3; ...
       4,2,5,3,7,1,9,8,6; ...
       9,1,6,8,4,2,3,5,7; ...
       7,8,3,6,5,9,2,4,1];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here is the Sudoku to be checked:\n' );
  fprintf ( 1, '\n' );

  sudoku_print ( s );
  
  check = sudoku_check ( s );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  SUDOKU_CHECK = %d:\n', check );
  fprintf ( 1, '  (Correctly filled in puzzle.  CHECK = 0 is expected.\n' );

  s = [ ...
       0,0,1,9,2,7,5,6,0; ...
       6,9,2,1,8,5,7,3,4; ...
       0,5,7,4,0,3,1,0,2; ...
       0,0,0,2,9,6,8,7,5; ...
       2,7,8,5,0,4,6,0,0; ...
       5,6,9,7,0,8,4,2,3; ...
       0,2,5,3,7,0,9,8,6; ...
       0,1,0,0,4,0,3,0,0; ...
       7,0,3,6,0,0,2,4,1];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here is the Sudoku to be checked:\n' );
  fprintf ( 1, '\n' );

  sudoku_print ( s );
  
  check = sudoku_check ( s );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  SUDOKU_CHECK = %d:\n', check );
  fprintf ( 1, '  (Partially filled in puzzle.  CHECK = 0 is expected.\n' );



  s = [ ...
       0,0,1,9,2,7,5,6,0; ...
       6,9,2,1,8,5,7,3,4; ...
       0,5,7,4,0,3,1,11,2; ...
       0,0,0,2,9,6,8,7,5; ...
       2,7,8,5,0,4,6,0,0; ...
       5,6,9,7,0,8,4,2,3; ...
       0,2,5,3,7,0,9,8,6; ...
       0,1,0,0,4,0,3,0,0; ...
       7,0,3,6,0,0,2,4,1];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here is the Sudoku to be checked:\n' );
  fprintf ( 1, '\n' );

  sudoku_print ( s );
  
  check = sudoku_check ( s );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  SUDOKU_CHECK = %d:\n', check );
  fprintf ( 1, '  (Illegal 11 in A(3,8).  CHECK = 38 is expected.\n' );

  s = [ ...
       0,0,1,9,2,7,5,6,0; ...
       6,0,2,1,8,5,7,3,4; ...
       0,5,7,4,0,3,1,0,2; ...
       0,9,0,2,9,6,8,7,5; ...
       2,7,8,5,0,4,6,0,0; ...
       5,6,9,7,0,8,4,2,3; ...
       0,2,5,3,7,0,9,8,6; ...
       0,1,0,0,4,0,3,0,0; ...
       7,0,3,6,0,0,2,4,1];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here is the Sudoku to be checked:\n' );
  fprintf ( 1, '\n' );

  sudoku_print ( s );
  
  check = sudoku_check ( s );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  SUDOKU_CHECK = %d:\n', check );
  fprintf ( 1, '  (Repeated 9 in row 4, col 5.  CHECK = 145 is expected.\n' );

  s = [ ...
       0,0,1,9,2,7,5,6,0; ...
       6,9,2,1,8,5,7,3,4; ...
       0,5,7,4,0,3,1,0,2; ...
       0,0,0,2,9,6,8,7,3; ...
       2,7,8,5,0,4,6,0,0; ...
       5,6,9,7,0,8,4,2,3; ...
       0,2,5,3,7,0,9,8,6; ...
       0,1,0,0,4,0,3,0,0; ...
       7,0,3,6,0,0,2,4,1];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here is the Sudoku to be checked:\n' );
  fprintf ( 1, '\n' );

  sudoku_print ( s );
  
  check = sudoku_check ( s );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  SUDOKU_CHECK = %d:\n', check );
  fprintf ( 1, '  (Repeated 3 in row 6, column 9.  CHECK = 269 is expected.\n' );

  s = [ ...
       0,0,1,9,2,7,5,6,0; ...
       6,9,2,1,8,5,7,3,4; ...
       0,0,7,4,0,3,1,0,2; ...
       0,0,0,2,9,6,8,7,5; ...
       2,7,8,5,0,4,6,0,0; ...
       5,6,9,7,0,8,4,2,3; ...
       0,2,5,3,7,0,9,8,6; ...
       0,5,0,0,4,0,3,0,0; ...
       7,0,3,6,0,0,2,4,1];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here is the Sudoku to be checked:\n' );
  fprintf ( 1, '\n' );

  sudoku_print ( s );
  
  check = sudoku_check ( s );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  SUDOKU_CHECK = %d:\n', check );
  fprintf ( 1, '  (Repeated 5 at A(8,2) in box (3,1).  CHECK = 382 is expected.\n' );

  return
end
