#### CSCI.4430/6969 Programming Languages Spring 2013 Programming Assignment #1

This assignment is to be done either individually or in pairs. Do not show your code to any other group and do not look at any other group's code. Do not put your code in a public directory or otherwise make it public. However, you may get help from the TAs or the instructor. You are encouraged to use the RPILMS Discussions page to post problems so that other students can also answer/see the answers.

### RPI Flu Epidemic

It is Flu season at RPI. Student Ashley has been infected and is avoiding contact with student Eric to ensure he does not get the Flu. However, Ashley is still going about her daily routine on campus and coming in contact with her friends. Every friend she converses with also gets the Flu. After acquiring the Flu, those students also give the Flu to every student they converse with. Assume the following students have conversations with the following friends:

• Ashley converses with John and Nate.
• Nate converses with Sam and Matt and Adam.
• Adam converses with Nate and Wayne.
• Wayne converses with Charles and George.
• Charles converses with Sam.
• George converses with Adam and Sam and Matt.
• Eric converses with Charles.

The order in which these conversations took place is not known to us. Is Eric safe from the Flu? If not, how many possible infection paths are there from Ashley to Eric? Create a simple program in Prolog to print out all possible solutions. (Please note these are not group conversations. For example, when 'Ashley converses with John and Nate', she converses with John and Nate in separate conversations.)

### Natural Language Processing with students in a line

For this problem, students labeled 'a' through 'f' are standing in a straight line. Create a Prolog program that allows the user to manipulate this line of students through natural language. A simple grammar can parse commands such as "Switch person a with person b." The parser then converts these sentences into simple commands. There is also the limitation that students may only switch with a student directly in front of them or behind them, as switching with students too far away will cause chaos in the line. After creating the command idiom for "switch X with Y", create the question idioms "Where is X in line?" which prints that student's position in line and "What is the current order of the line?" which prints out the line (ex: "a,c,b,d,e,f").