Home  |   Notes  |   Languages  |   Programs  |   Homework
Program Assignment 3

100 Points
Due: 11/14/01 at the start of class

 Problem

This is your first assignment in Prolog, and is intended to demonstrate a capability in the language that is difficult to implement in any other language.

Design, implement and fully test, a Prolog program that will solve the following logic problem:

There are 5 houses, each of a different color and inhabited by a man of a different nationality, with a different pet, drink, and dessert choice. From the clues given below, determine which person lives in which house, what kind of pet they own, what their favorite drink is, and what their favorite dessert is.

The complete set of data for this puzzle is:

House Colors: bluegreenivoryredyellow
Nationalities: EnglishmanJapaneseNorwegianSpaniardUkrainian
Pets: dogfoxhorsesnailszebra
Drinks: Coffeemilkorange juiceteawater
Desserts: ice creampiecakechocolatemousse

The clues you have available are:

For this program, there is no interactive input data. Further, your program must produce a solution within 1 minute of execution time.

 Implementation Language

For this assignment, your program must be written in Prolog. You will be programming in a "logic programming" style, as described in Chapter 15 of the text book. Since this program must be written in Prolog, appropriate use of logic programming language features is expected. In particular, you may not use any versions of assert, retract, record, erase, flag, or any of the other database features of Prolog.

As with prior programs, your solution must adhere to good programming style, including correct use of parameter passing, identifier naming, predicate length, commenting, headers for each predicate, etc.

 Input/Output Format

Write your program as a prolog predicate called house_solution taking 20 unbound variables as parameters, like this:

    house_solution(
            Blue_Nationality,   Blue_Pet,   Blue_Drink,   Blue_Dessert,
            Green_Nationality,  Green_Pet,  Green_Drink,  Green_Dessert,
            Ivory_Nationality,  Ivory_Pet,  Ivory_Drink,  Ivory_Dessert,
            Red_Nationality,    Red_Pet,    Red_Drink,    Red_Dessert,
            Yellow_Nationality, Yellow_Pet, Yellow_Drink, Yellow_Dessert
        ) :-  /* your implementation here */
            ...
The Curator will invoke your solution with 20 unbound variables and then print out the results using write goals.

 Submitting Your Program

Your Prolog implementation is to be organized in a single file. All documentation and identifying information should be placed in comments within the single source file. The comments at the beginning of the file should identify the assignment and give your full name. Every Prolog predicate should be preceded by comments explaining its purpose and implementation.

Your program will be submitted electronically through the Curator for automatic grading. To submit your program, login to the Curator using your PID and password. Be sure to select the 91312-CS 3304 Edwards 2:30-3:45 MW section when logging in. Click on "Submit", choose 3-Prolog from the project drop-down list, click "Browse" to specify your solution, and then click "Upload."

In addition, you must also turn in a printed version of your program source in class according to the rules specified in the syllabus, which also describes the late policy. Your hardcopy printout must match the highest-scoring submission sent to the Curator earliest. In other words, you may not submit your program until it works, go back and add comments and documentation, and then make a final submission of the printable version of your program. Once you receive full credit from the Curator on a submission, that is the version you must print and hand in.


Home  |   Notes  |   Languages  |   Programs  |   Homework

copyright © 2001 Virginia Tech, ALL RIGHTS RESERVED
Last modified: November 27, 2001, 13:58:28 EST, by Stephen H. Edwards <edwards@cs.vt.edu>