sudoku_bat/solver/cellset.c

32 lines
548 B
C
Raw Permalink Normal View History

2024-05-25 23:08:47 +00:00
#include "cellset.h"
void cellset_init(cellset_t* row) {
row->count = 0;
}
void cellset_add(
cellset_t* row,
uint8_t other
) {
for (uint8_t i = 0; i < row->count; i++) {
if (row->cells[i] == other) {
return;
}
}
if (row->count >= N_CELLS) {
crash("too many interference items");
}
row->cells[row->count++] = other;
}
void cellset_add_exclude(
cellset_t* row,
uint8_t exclude,
uint8_t other
) {
if (other == exclude) { return; }
cellset_add(row, other);
}