Exercise #8

The exercise this time is to write a program that reads in the information that incoming students provide about their tutorial preferences and assigns students to tutorials in such a way as to satisfy as many students as possible.

The file /home/stone/courses/scheme/tutorial.dat contains the tutorial preferences of 396 incoming students in the following format: Columns 1 through 3 of each line contain a serial number by which the student will be identified; these are simply integers in the range from 1 to 396. Columns 4 and 5 are spaces. The rest of the line contains five words, separated by single spaces; each word is the abbreviation of the title of a tutorial. For example, here is a typical line from the file:

254  Capitalism Bioethics Musicals Rights Adolescence

This indicates that student #254's first choice is the tutorial whose title contains the word `Capitalism'; her second choice is `Bioethics', her third choice `Musicals', and so on.

There are thirty-three tutorials altogether; their one-word abbreviated titles are `Utopia', `Spring', `Images', `Africa', `Problems', `Vernacular', `Philosophy', `Food', `Telephones', `Plants', `Musicals', `Perception', `Revolutions', `Rights', `China', `Behavior', `Aristotle', `Humans', `Autobiography', `Ethics', `Experience', `Rebirth', `Republic', `Adolescence,' `Crime', `Women', `Change', `Cryptology', `Detectives', `Capitalism', `Picasso', `Orwell', and `Bioethics'.

The output from your program should consist of thirty-three lines, each beginning with one of these one-word titles (left-justified in columns 1 through 15) and subsequently containing the serial numbers of the twelve students assigned to that tutorial, separated by spaces. The program may not assign more than twelve students to any tutorial, no matter how many of them declare a preference for it. Naturally, each student's serial number should appear exactly once in the output. A typical line of output might look like this:

Adolescence    255 129 18 321 150 68 286 162 120 202 27 157

To assess how well your program succeeds, I'll award twenty points for each student who is assigned to the tutorial that he announces as his first choice, ten points for a second-choice assignment, five for a third-choice assignment, two for a fourth-choice assignment, and one for a fifth-choice assignment.


This document is available on the World Wide Web as

http://www.math.grin.edu/~stone/courses/scheme/exercise-8.html

created May 1, 1998
last revised June 9, 1998

John David Stone (stone@math.grin.edu)