This would be much easier to solve with pen and paper. But I'll take a crack at the groundwork.

I would start out with identifying the kinds of logical relations.

- x implies y
- x is next to y
- x to the right of y
- x is in house number i

Then one needs to identify what house attributes are available and their possible values.

- colour: red green blue yellow ivory
- pet: dog snail fox horse [implied zebra]
- smoke: Old Gold, Kools, Chesterfield, Lucky Strike, Parliaments
- drink: coffee tea milk OJ [implied gin & tonic, obviously]
- nationality: English, Ukrainian, Spanish, Norwegian, Japanese

From the standpoint of the puzzle, houses are an array of containers for the above attributes (house number, colour, etc).

The first step is to put down things that can't change, the rules which specify house number should be applied as well as any that can be directly applied (in this case just that the blue house is next to the Norwegian, there aren't any other direct relations).

**Code:**

number | 1 | 2 | 3 | 4 | 5 |

colour | | blue | | | |

pet | | | | | |

smoke | | | | | |

drink | | | milk | | |

nationality | norwegian | | | | |

The puzzle doesn't have any other rules we can apply directly so we need to eliminate the possible options in each cell until only 1 option remains. Referring to our logical relations, the ways of eliminating options are:

- x implies y: (1) eliminate x from all houses that are not y, vice-versa for y.
- x is next to y: (1) where either x or y is known, eliminate the other from all cells not next to the known one.
- x to the right of y: (1) eliminate x where a value to the left is known to be not y. eliminate y where a value to the right is known to be not x. (2) eliminate y from all the right-most houses, eliminate x from all the left-most houses

There might be a bunch of others but from here you can infer

1. house 1 has the norwegian, so by the first rule we can eliminate all the options involving nationality. -red, -tea, -parliament

2. eliminate green from house 1 because it's the left-most house.

3. eliminate ivory from hosue 1 because it's to the left of a known blue house.

3. the only colour left is yellow, so the first house is yellow.

If you carry on eliminating options then you should arrive at a solution. You just need to make sure that the list of methods to eliminate options is complete. So the general algorithm is:

**Code:**

while there are still unkown values in houses

{

check if any of the rules can be applied directly, without inference

eliminate potential values from all the houses until one of the attributes only has 1 possible value left

}