Program 1: Prolog

Due Date

This assignment is due at the beginning of the lecture on Thursday, February 12th.

Partners

You are required to work with one other person on this assignment. Please submit just one solution with both of your names on it.

Sample Solutions

Prolog

Purpose

The purpose of this assignment is to give you practice solving problems in Prolog.

Problem Description

Solve the following three problems:

  1. 20%. Write a Prolog program that calculates the number of days that separate two dates. For example,
    distance(date(january, 19, 2004), date(january, 20, 2004)).
    might print 1 day. Assume that the dates are valid and that the year is between 2000 and 2010.
  2. 50%. Write a Prolog expert system that can classify a 5 card poker hand as one of the following: straight flush, 4 of a kind, full house, flush, straight, 3 of a kind, 2 pair, pair, or nothing. For simplicity, treat an 11 as a jack, a 12 as a queen, a 13 as a king, and a 14 as an ace. For example,
    classify([card(11, hearts), card(7, hearts), card(5, hearts), card(11, clubs), card(7, spades)]).
    might print two-pair.
  3. 30%. Do something else of interest with Prolog. You should do something that involves different skills from those above and is non-trivial.

What to Submit

  1. A printout of the source code that you produce.
  2. A printout of your program running on the sample output of your choosing.

Grading

Valid XHTML 1.0!