CS 110, Project 2
Due: Friday, Sept. 23, 1:30 PM

1. Mastermind using Functions (60 points)

Rewrite your mastermind program so that it defines and calls functions named:

    printInstructions
    generateSecretCode 
    getGuess
    computeExactMatches
    computePartialMatches

Design Requirements

1. Clearly mark you 'main' program with a comment-- # main program starts here

2. Comment your code well-- describe what each part of code is doing.

3. Use descriptive variable names (and function names exactly as above)

4. Use a loop to compute exact matches and a nested loop to compute partial matches

2. Google API: Related Universities

a. (35 points) Write a program that uses the Google api to list the titles  of universities related to a given university. The program should ask the user to input the home page of some university (e.g., 'http://www.usfca.edu') and it should list the titles  of all related universities. Here, two universities a and b are said to be related if:

    Google finds that a's home page is directly related to b's homepage

        or

    Google finds that a page related to a's home page is related to b's homepage (a relation of a relation)

You must define a function, related(url) which returns a list of the related university home pages. The 'main' program should just print out the title of each of those pages.

Note that searching Google with the string 'related:http//www.usfca.edu' will return a list of all home pages related to http://www.usfca.edu. 'related:' is like the 'link:' searches, but instead of returning inward links it returns pages that Google deems similar.

b. (5 points) Modify your program so that the user can specify a distance which defines whether or not two universities are related. In problem 1, that distance is 2. Your function should now be related(url,distance).

Extra Credit

1. Find out the algorithm Google uses to compute 'related'? What does it really mean? Email your instructor a paragraph or two and links to the proof. (3 points)

2. Generalize your program's definition of 'related' by considering all inward links, all Google related links, and all outward links, as related.