Question: / * * * Check if assigning value to houses [ h ] [ a ] is valid * / public boolean valid ( int
Check if assigning value to housesha is valid
public boolean validint houses, int h int a int value
Use each value one time per column
for int i ; i houses.length; i
if housesia value
return false;
Provisional assignment
housesha value;
Check the constraints
boolean constraints britLivesInRedHousehouses
&& swedeKeepsDogshouses
&& daneDrinksTeahouses;
etc.
Undo test assignment
housesha NONE;
return
Start with only the britLivesInRedHouse constraint. Run your search and
verify that you can produce a solution with the Brit in the red house. The
other assignments will probably be incorrect, but thats okay.
Then add one more constraint, like swedeKeepsDogs. Run the solution again
and verify that youre now satisfying both constraints.
Continue, adding just one constraint at a time until you have all in place.
Who owns the fish
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
