@Jungibaaz The approach you adopted to solve zebra puzzle (as it is known) is called Brute-Force in problem solving. Brute-Force method usually requires a lot more work than other approaches and is thus considered inefficient for solving large and complex problems. Here is a simple way to solve the puzzle.
First of all fill the table values with the info given. This is what we get.
Nationality --------------- Job----------------- House Color -------------- Pet --------------- Drink
Englishman ------------------------------------------ Red ------------------------------------------------
Spaniard -------------------------------------------------------------------------- Dog --------------------
Japanese ---------------- Painter -------------------------------------------------------------------------
Italian ----------------------------------------------------------------------------------------------------- Tea
Norwegian-------------------------------------------------------------------------------------------------
Another table for plotting info with respect to house position can come handy.
1 ---------------------- 2 -------------------- 3 ------------------ 4 -------------------- 5
Norwegian ------- Blue ---------------- Milk ----------------------------------------
Now consider ‘green house is on the right of the white one’. What could be the positions of white and green houses? White house cant be house#1 because that will mean green house is #2 but we know house #2 is blue. So that means white and green houses occupy either positions 3 and 4 or 4 and 5. This means Norwegian’s house cannot be white,green or blue. It cant be red either cause that’s the color of Englishmans house. So we are only left with yellow. That’s the color of Norwegian’s house. We make this entry in our table. We now have,
Nationality ---------------- Job------------ House Color ----------------- Pet --------------- Drink
Englishman ------------------------------------- Red ---------------------------------------------------
Spaniard ------------------------------------------------------------------------- Dog --------------------
Japanese ----------------- Painter ----------------------------------------------------------------------
Italian ------------------------------------------------------------------------------------------------- Tea
Norwegian ------------------------------------- Yellow ------------------------------------------------
Now diplomat lives in the yellow house. This means Norwegian is a diplomat. We make the entry in our table.
Nationality ----------------- Job ------------- House Color --------------- Pet --------------- Drink
Englishman ----------------------------------------- Red-------------------------------------------------
Spaniard --------------------------------------------------------------------------- Dog --------------------
Japanese ------------------ Painter ----------------------------------------------------------------------
Italian --------------------------------------------------------------------------------------------------- Tea
Norwegian --------------- Diplomat -------------- Yellow ----------------------------------------------
Horse lives next to diplomat so horse lives in house #2.
1 --------------------- 2 ----------------- 3 --------------- 4 ----------------- 5
Norwegian ------ Blue ------------- Milk ----------------------------------
--------------------- Horse -----------------------------------------------------
Now consider the drink of Norwegian. It cant be tea, Italian drinks it. It cant be coffee cause its drunk in green house which lies at position 4 or 5. It isn’t milk cause milk is drunk in middle house. And it cant be orange juice cause violinist drinks it. So we are only left with water. We make the entry.
Nationality ----------------- Job ----------- House Color ----------------- Pet -------------- Drink
Englishman --------------------------------------- Red -------------------------------------------------
Spaniard -------------------------------------------------------------------------- Dog -------------------
Japanese ------------------ Painter ---------------------------------------------------------------------
Italian -------------------------------------------------------------------------------------------------- Tea
Norwegian --------------- Diplomat ------------ Yellow ------------------------------------------ Water
Now consider the color of houses. First one is yellow, second is blue. Houses 3,4 and 5 have colors white, green and red in some order we don’t know yet. Because green lies to the right of white, the white and green houses occupy either positions 3 and 4 respectively or positions 4 and 5 respectively. That means red house is either #3 or else #5. Which says Englishman lives in house #3 or else house #5. So we are down to two possible locations for the Englishman. We check both possibilities. When we assign the Englishman house #5 and fill out the table using the conclusions it leads to we find out that it leads to contradictions. That means the Englishman must live in house #3. So we now know house #3 is red. And the Englishman drinks milk. That also means that houses 4 and 5 are white and green respectively. We fill out the tables.
1 --------------------- 2 ----------------- 3 -------------------- 4 ------------------ 5
Norwegian ------- Blue ------------ Milk --------------- White ------------ Green
Yellow ------------ Horse ------- Englishman ------------------------------- Coffee
Diplomat ----------------------------- Red ------------------------------------------
Water -----------------------------------------------------------------------------------
Nationality ----------------- Job ------------- House Color --------------- Pet ---------------- Drink
Englishman ----------------------------------------- Red --------------------------------------------- Milk
Spaniard -------------------------------------------------------------------------- Dog --------------------
Japanese ------------------ Painter ----------------------------------------------------------------------
Italian --------------------------------------------------------------------------------------------------- Tea
Norwegian --------------- Diplomat -------------- Yellow ----------------------------------------- Water
Now consider the drink of Japanese. It is either coffee or orange juice. It cant be orange juice cause violinist drinks it and Japanese is a painter. That means Japanese drinks coffee and live is house #5. Spaniard is left with orange juice, which means he is a violinist. We fill the tables.
Nationality ------------------ Job ------------ House Color --------------- Pet --------------- Drink
Englishman ------------------------------------------ Red -------------------------------------------- Milk
Spaniard -------------------- Violinist ------------------------------------------- Dog ------------ Orange juice
Japanese ------------------- Painter -------------- Green ----------------------------------------- Coffee
Italian --------------------------------------------------------------------------------------------------- Tea
Norwegian ---------------- Diplomat ------------- Yellow ------------------------------------------ Water
1 ----------------------- 2 --------------- 3 ------------------- 4 ------------------ 5
Norwegian --------- Blue ----------- Milk -------------- White ------------ Green
Yellow -------------- Horse ------- Englishman ---------------------------- Coffee
Diplomat ------------------------------ Red------------------------------------Japanese
Water ---------------------------------------------------------------------------- Painter
Now we consider the house color of Spaniard which is either blue or white. It cant be blue because in the blue house horse lives and Spaniard has a dog. So that means Spaniard lives in white house. We fill the tables.
Nationality ------------------ Job ------------ House Color --------------- Pet ----------------- Drink
Englishman ----------------------------------------- Red ------------------------------------------------ Milk
Spaniard ------------------- Violinist ------------- White ---------------------- Dog -------------- Orange juice
Japanese ------------------- Painter ------------- Green -------------------------------------------- Coffee
Italian ------------------------------------------------------------------------------------------------------- Tea
Norwegian ---------------- Diplomat ------------- Yellow ------------------------------------------- Water
1 --------------------- 2 ------------------ 3 -------------------- 4 ------------------- 5
Norwegian ------ Blue -------------- Milk --------------- White ------------ Green
Yellow ----------- Horse --------- Englishman --------- Spaniard --------- Coffee
Diplomat ------------------------------ Red --------------- Violinist --------- Japanese
Water --------------------------------------------------------- Dog -------------- Painter
-------------------------------------------------------------- Orange Juice
Four houses have been assigned drinks in the above table that leaves house #2 with Tea. So Italian lives in house #2 which is blue and has a horse. We make the entries.
Nationality ----------------- Job ------------ House Color ---------------- Pet ---------------- Drink
Englishman --------------------------------------- Red ------------------------------------------------ Milk
Spaniard ------------------ Violinist ------------ White ----------------------- Dog ------------- Orange juice
Japanese ------------------ Painter ------------- Green --------------------------------------------- Coffee
Italian ----------------------------------------------- Blue ----------------------- Horse --------------- Tea
Norwegian --------------- Diplomat ----------- Yellow -------------------------------------------- Water
1 --------------------- 2 ------------------ 3 -------------------- 4 ------------------ 5
Norwegian ------- Blue ------------- Milk --------------- White ------------ Green
Yellow ------------ Horse -------- Englishman -------- Spaniard ---------- Coffee
Diplomat ---------- Tea -------------- Red -------------- Violinist--------- Japanese
Water ------------- Italian ---------------------------------- Dog ------------- Painter
------------------------------------------------------------- Orange Juice
Now Italian is either a photographer or a physician. He cant be a photographer because photographer breeds snails and the Italian has a horse. So Englishman is the photographer and Italian is the physician. We make the entries.
Nationality -------------------- Job ---------------House Color ------------ Pet --------------- Drink
Englishman -------------- Photographer ------------ Red ------------------ Snails --------------- Milk
Spaniard --------------------- Violinist ---------------- White ----------------- Dog ------------ Orange juice
Japanese -------------------- Painter ---------------- Green ------------------------------------- Coffee
Italian ----------------------- Physician ---------------- Blue ----------------- Horse -------------- Tea
Norwegian ----------------- Diplomat --------------- Yellow ------------------------------------- Water
1 ------------------------ 2 ----------------- 3 -------------------- 4 ------------------ 5
Norwegian --------- Blue ------------- Milk --------------- White ----------- Green
Yellow -------------- Horse -------- Englishman --------- Spaniard -------- Coffee
Diplomat ------------ Tea -------------- Red --------------- Violinist -------- Japanese
Water --------------- Italian ------- Photographer --------- Dog ------------ Painter
----------------------Physician --------- Snails ----------- Orange Juice ------------
Now we have ‘fox is in a house next to that of the physician’. Physician is Italian in house #2. That means either one of house #1 and house #3 has a fox. But house #3 has snails. So fox is in house #1, which is Norwegian’s. This completes our table.
Nationality ------------------ Job ------------- House Color -------------- Pet -------------- Drink
Englishman ----------- Photographer ---------- Red --------------------- Snails ------------ Milk
Spaniard ------------------ Violinist ------------- White -------------------- Dog ---------- Orange juice
Japanese ------------------ Painter -------------- Green ------------------- Zebra ----------- Coffee
Italian -------------------- Physician --------------- Blue ------------------- Horse ------------- Tea
Norwegian -------------- Diplomat ------------- Yellow ------------------- Fox ------------- Water
@levina