C463/B551 Artificial Intelligence

Homework 2

Due date: Thursday, January 24, 2008.

Implement the following in either Python or Elisp.

Ex. 1 Write a function that inputs an integer from the user representing a number of dollars. Test if the value entered by the user is anything but an integer, and in the case where it isn't, print an error message. Otherwise the function should print out the conversion of the number to the smaller number of bills, considering that the $100 bill is the highest. For example, if the user enters 145, then the function should print out that you need 1 $100 bill, 2 $20 bills, and 1 $5 bill.

Ex. 2 Write two functions called intersection and union. Each of them should take two parameters, both of which can have default values equal to an empty list/array ([]). The first function should return a list/array containing all the elements that the two parameters have in common (in any order you want). The second one should return an array containing the combination of the two lists/arrays without duplicating the elements that are common. If the two lists contain each non repeating elements (some of which might occur in both), then the returned list should not have any duplicates.

Hint: In Python, the operator in returns True if a value is in a list. For example
2 in [2,3,4]
returns True.

Turn in: all the functions in one file, by email only. Show a few examples of calling the functions you wrote.