src/sudoku.c
l_int32
sudokuTestUniqueness(l_int32  *array,
                     l_int32  *punique)
{
l_int32    same1, same2, same3;
l_int32   *array1, *array2, *array3;
L_SUDOKU  *sud, *sud1, *sud2, *sud3;

    PROCNAME("sudokuTestUniqueness");

    if (!punique)
        return ERROR_INT("&unique not defined", procName, 1);
    *punique = 0;
    if (!array)
        return ERROR_INT("array not defined", procName, 1);

    sud = sudokuCreate(array);
    sudokuSolve(sud);
    array1 = sudokuRotateArray(array, 1);
    sud1 = sudokuCreate(array1);
    sudokuSolve(sud1);
    array2 = sudokuRotateArray(array, 2);
    sud2 = sudokuCreate(array2);
    sudokuSolve(sud2);
    array3 = sudokuRotateArray(array, 3);
    sud3 = sudokuCreate(array3);
    sudokuSolve(sud3);

    sudokuCompareState(sud, sud1, 1, &same1);
    sudokuCompareState(sud, sud2, 2, &same2);
    sudokuCompareState(sud, sud3, 3, &same3);
    *punique = (same1 && same2 && same3);

    sudokuDestroy(&sud);
    sudokuDestroy(&sud1);
    sudokuDestroy(&sud2);
    sudokuDestroy(&sud3);
    FREE(array1);
    FREE(array2);
    FREE(array3);
    return 0;
}
/*!
 *  sudokuTestUniqueness()
 *
 *      Input:  array (of 81 numbers, 9 lines of 9 numbers each)
 *              &punique (<return> 1 if unique, 0 if not)
 *      Return: 0 if OK, 1 on error
 *
 *  Notes:
 *      (1) This applies the brute force method to all four 90 degree
 *          rotations.  If there is more than one solution, it is highly
 *          unlikely that all four results will be the same;
 *          consequently, if they are the same, the solution is
 *          most likely to be unique.
 */
sudokuTestUniqueness()
Input:  array (of 81 numbers, 9 lines of 9 numbers each)
&punique ( 1 if unique, 0 if not)
Return: 0 if OK, 1 on error

(1) This applies the brute force method to all four 90 degree
rotations.  If there is more than one solution, it is highly
unlikely that all four results will be the same;
consequently, if they are the same, the solution is
most likely to be unique.
sudokuTestUniqueness () Input : array ( of 81 numbers 9 lines of 9 numbers each ) &punique ( 1 if unique 0 if not ) Return : 0 if OK 1 on error ( 1 ) This applies the brute force method to all four 90 degree rotations . If there is more than one solution it is highly unlikely that all four results will be the same ; consequently if they are the same the solution is most likely to be unique .
l_int32
sudokuTestUniqueness(l_int32  *array,
                     l_int32  *punique)
{
l_int32    same1, same2, same3;
l_int32   *array1, *array2, *array3;
L_SUDOKU  *sud, *sud1, *sud2, *sud3;
    PROCNAME("sudokuTestUniqueness");
    if (!punique)
        return ERROR_INT("&unique not defined", procName, 1);
    *punique = 0;
    if (!array)
        return ERROR_INT("array not defined", procName, 1);
    sud = sudokuCreate(array);
    sudokuSolve(sud);
    array1 = sudokuRotateArray(array, 1);
    sud1 = sudokuCreate(array1);
    sudokuSolve(sud1);
    array2 = sudokuRotateArray(array, 2);
    sud2 = sudokuCreate(array2);
    sudokuSolve(sud2);
    array3 = sudokuRotateArray(array, 3);
    sud3 = sudokuCreate(array3);
    sudokuSolve(sud3);
    sudokuCompareState(sud, sud1, 1, &same1);
    sudokuCompareState(sud, sud2, 2, &same2);
    sudokuCompareState(sud, sud3, 3, &same3);
    *punique = (same1 && same2 && same3);
    sudokuDestroy(&sud);
    sudokuDestroy(&sud1);
    sudokuDestroy(&sud2);
    sudokuDestroy(&sud3);
    FREE(array1);
    FREE(array2);
    FREE(array3);
    return 0;
}
l_int32 sudokuTestUniqueness ( l_int32 * array , l_int32 * punique ) { l_int32 same1 , same2 , same3 ; l_int32 * array1 , * array2 , * array3 ; L_SUDOKU * sud , * sud1 , * sud2 , * sud3 ; PROCNAME ( " " ) ; if ( ! punique ) return ERROR_INT ( " " , procName , 1 ) ; * punique = 0 ; if ( ! array ) return ERROR_INT ( " " , procName , 1 ) ; sud = sudokuCreate ( array ) ; sudokuSolve ( sud ) ; array1 = sudokuRotateArray ( array , 1 ) ; sud1 = sudokuCreate ( array1 ) ; sudokuSolve ( sud1 ) ; array2 = sudokuRotateArray ( array , 2 ) ; sud2 = sudokuCreate ( array2 ) ; sudokuSolve ( sud2 ) ; array3 = sudokuRotateArray ( array , 3 ) ; sud3 = sudokuCreate ( array3 ) ; sudokuSolve ( sud3 ) ; sudokuCompareState ( sud , sud1 , 1 , & same1 ) ; sudokuCompareState ( sud , sud2 , 2 , & same2 ) ; sudokuCompareState ( sud , sud3 , 3 , & same3 ) ; * punique = ( same1 && same2 && same3 ) ; sudokuDestroy ( & sud ) ; sudokuDestroy ( & sud1 ) ; sudokuDestroy ( & sud2 ) ; sudokuDestroy ( & sud3 ) ; FREE ( array1 ) ; FREE ( array2 ) ; FREE ( array3 ) ; return 0 ; }
sudokuTestUniqueness()
      Input:  array (of 81 numbers, 9 lines of 9 numbers each)
              &punique (<return> 1 if unique, 0 if not)
      Return: 0 if OK, 1 on error
sudokuTestUniqueness () Input : array ( of 81 numbers 9 lines of 9 numbers each ) &punique ( <return > 1 if unique 0 if not ) Return : 0 if OK 1 on error