Starting from:

$25

CSC 421: Assignment 2 - Solved.

CSC 421: Assignment 2 - Part B 

Q3. (6 points) Nim is a kind of game in which players take turn to removing objects from some initial configuration. A particular version of the Nim is: there is a pile of 13 coins on the table, on each turn, players take either 1, 2, or 3 coins from the pile and put them aside.  The objective of the game is to avoid being forced to take the last coin. Using the framework provided in connex, and seeing the TicTacToe game as an example, implement the Nim game. 
Q4. (6 points) Consider the following puzzle: In five houses, each with a different color, live 5 persons of different nationalities, each of whom prefer a different brand of cigarette, a different drink, and a different pet. Given the following facts, the question to answer is “Where does the zebra live, and in which house do they drink water?”  
1.The Englishman lives in the red house.  
2.The Spaniard owns a dog.  
3.Coffee is drunk in the green house.  
4.The Ukrainian drinks tea.  
5.The green house is directly to the right of the ivory house.  
6.The Old-Gold smoker owns snails.  
7.Kools are being smoked in the yellow house.  
8.Milk is drunk in the middle house.  
9.The Norwegian lives in the first house on the left.  
10.The Chesterfield smoker lives next to the fox owner.  
11.Kools are smoked in the house next to the house where the horse is kept.  
12.The Lucky-Strike smoker drinks orange juice.  
13.The Japanese smokes Parliament.  
14.The Norwegian lives next to the blue house.  
Formulate the problem as CSP, code it, and find the solution. (partial code provided) 
Hint. Use the last formulation discussed in class and slides. Do not forget the uniqueness constraints, e.g. red should be different from green, blue, etc, milk should be different from coffee, tea, etc, and so on, for each group of variables. Use loops wherever possible to avoid specifying everything by hand.   

More products