Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * * * 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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started