Question: This code is for solving the Einstein Who Owns the Fish puzzle. Right now all I get is No solution found. I can't post the

This code is for solving the Einstein Who Owns the Fish puzzle. Right now all I get is No solution found. I can't post the whole code but here is snippets of the logic:
import java.util.Arrays;
public class WhoOwnsTheFish {
// Constants for each possible value
private final int NONE =-1;
private final int NATIONALITY =0;
private final int COLOR =1;
private final int DRINKS =2;
private final int SMOKES =3;
private final int PET =4;
private final int NORWEGIAN =0;
private final int DANE =1;
private final int BRIT =2;
private final int GERMAN =3;
private final int SWEDE =4;
private final int WATER =0;
private final int TEA =1;
private final int COFFEE =2;
private final int BEER =3;
private final int MILK =4;
private final int DUNHILLS =0;
private final int BLENDS =1;
private final int PALLMALLS =2;
private final int PRINCES =3;
private final int BLUEMASTERS =4;
private final int CAT =0;
private final int HORSE =1;
private final int BIRD =2;
private final int FISH =3;
private final int DOG =4;
private final int BLUE =0;
private final int GREEN =1;
private final int RED =2;
private final int YELLOW =3;
private final int WHITE =4;
public boolean valid (int[][] houses, int h, int a, int value){
// is the value assigned to another house
for(int i =0; i < houses.length; i++){
if(i != h && houses[i][a]== value){
return false;
}
}
// switch case to check the attribute and the value
switch(a){
// START HERE
// the brit lives
case NATIONALITY:
if (value == BRIT && houses[h][COLOR]!= NONE && houses[h][COLOR]!= RED){
return false;
}
// the Swede keeps dogs as pets
if (value == SWEDE && houses[h][PET]!= NONE && houses[h][PET]!= DOG){
return false;
}
// the Dane drinks tea
if(value == DANE && houses[h][DRINKS]!= NONE && houses[h][DRINKS]!= TEA){
return false;
}
// the Norwegian lives in the first house
if(value == NORWEGIAN && h !=0){
return false;
}
// the German smokes Princes
if(value == GERMAN && houses[h][SMOKES]!= NONE && houses[h][SMOKES]!= PRINCES){
return false;
}
break;
case COLOR:
// the Brit lives in the red house
if(value == RED && houses[h][NATIONALITY]!= NONE && houses[h][NATIONALITY]!= BRIT){
return false;
}
// the green house is on the left of and next to the
// white house
if(value == GREEN && (h ==4|| houses[h +1][COLOR]!= NONE && houses[h +1][COLOR]!= WHITE)){
return false;
}
if (value == WHITE && (h ==0|| houses[h -1][COLOR]!= NONE && houses[h -1][COLOR]!= GREEN)){
return false;
}
// the owner of the yellow house smokes dunhills, which means that the owner of the yellow house is the Norwegian
if(value == YELLOW && houses[h][SMOKES]!= NONE && houses[h][SMOKES]!= DUNHILLS){
return false;
}
// the Norwegian lives next to the blue house
if (value == BLUE && (h !=1 && h !=4|| houses[h +1][NATIONALITY]!= NONE && houses[h -1][NATIONALITY]!= NORWEGIAN)){
return false;
}
break;
case DRINKS:
// the green houses owner drinks coffe, which is the German
if(value == COFFEE && houses[h][NATIONALITY]!= NONE && houses[h][COLOR]!= GREEN){
return false;
}
if (value == TEA && houses[h][NATIONALITY]!= NONE && houses[h][NATIONALITY]!= DANE){
return false;
}
// the man living in the center house drinks milk
if(value == MILK && h !=2){
return false;
}
// The owner who smokes Bluemasters drinks beer
if (value == BEER && houses[h][SMOKES]!= NONE && houses[h][SMOKES]!= BLUEMASTERS){
return false;
}
// The man who smokes Blends has a neighbor who drinks water
if (value == WATER && (h ==0|| h ==4|| houses[h -1][SMOKES]!= NONE && houses[h -1][SMOKES]!= BLENDS) && (h ==4|| h ==0|| houses[h +1][SMOKES]!= NONE && houses[h +1][SMOKES]!= BLENDS)){
return false;
}
break;
case SMOKES:
// The person who smokes Pall Mall rears birds
if (value == PALLMALLS && houses[h][PET]!= NONE && houses[h][PET]!= BIRD){
return false;
}
// The owner of the yellow house smokes Dunhills
if (value == DUNHILLS && houses[h][COLOR]!= NONE && houses[h][COLOR]!= YELLOW){
return false;
}
// The man who smokes Blends li

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!