/* puts each element into bit vector to check digits */ void check_setof9(int col, int row, UArray2_T a, void *elem, void *bit) { int digit = *(int *)elem; Bit_T b = bit; if (digit < 1 || digit > 9) { Bit_free(&b); UArray2_free(&a); exit(1); /* digit is already in vector */ } if (Bit_get(bit, digit) == 1) { Bit_free(&b); UArray2_free(&a); exit(1); /* if digit isn't in vector, change bit to 1 */ } else { Bit_put(bit, digit, 1); /*all nine digits are present, reset bit vector*/ } if (Bit_count(bit) == 9) { Bit_clear(bit, 1, 9); } (void) col; (void) row; (void) a; }
/* * Returns the number of ones in the bit2 array */ extern int Bit2_count(T bit2) { return (Bit_count (bit2->bit_vector)); }