Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool
- subgrid_consistency (pset_t *subgrid[grid_size])
- /*
- * subgrid_consistency check if subgrid is consistent
- *
- * a subgrid is consistent if and only if :
- * _ each color appears once at least in subgrid
- * _ two singleton in subgrid are not the same
- *
- * RETURN VALUE : true if subgrid is consistent, false otherwise
- */
- {
- unsigned int i;
- pset_t color_appeared, color_singleton;
- bool singleton = true;//true if each singleton in subgrid appears no more once
- color_appeared = pset_empty();
- color_singleton = pset_empty();
- for (i = 0; i < grid_size; i++)
- {
- if (pset_is_singleton(*subgrid[i]))
- {
- if (pset_is_included(*subgrid[i], color_singleton))
- {
- //subgrid[i] is a singleton ever met before
- singleton = false;
- break;
- }
- color_singleton = pset_or(color_singleton, *subgrid[i]);
- }
- color_appeared = pset_or(color_appeared, *subgrid[i]);
- }
- return pset_is_included(pset_full(grid_size), color_appeared) && singleton;
- }
- bool
- grid_consistency (pset_t **grid)
- /*
- * grid_consistency check if grid is consistency
- *
- * a grid is consistent if and only if each subgrid is consistent
- *
- * a subgrid is consistent if and only if :
- * _ each color appears once at least in subgrid
- * _ two singleton in subgrid are not the same
- *
- * RETURN VALUE : true if grid is consistent, false otherwise
- */
- {
- return subgrid_map(grid, subgrid_consistency);
- }
Add Comment
Please, Sign In to add comment