# Ryan Martin
# macid: abcd123
# student number: #######
# July 12, 2011
#
# This is a solution for Marked Assignment 2 (Lab 05) on Friday.

def main():

    print """\

This program is a solution to Marked Assignment 2 (Lab 05) on Friday.

"""

    #INPUTS
    
    searchFileName = raw_input("Enter the name of the input file containing search words: ")
    searchFile = open(searchFileName, "r")
    searchList = searchFile.read().split()
    searchFile.close()
    
    wordFileName = raw_input("Enter the name of the input file containing random words: ")
    wordFile = open(wordFileName, "r")
    wordList = wordFile.read().split()
    wordFile.close()
    print 

    #COMPUTATION

    totalMatches = 0
    for searchWord in searchList: 
        totalMatches = totalMatches + wordList.count(searchWord)

    '''Alternative method (one of many):
    
    for i in range(len(searchList)):
        totalMatches = totalMatches + wordList.count(searchList[i])
    
    '''

    #OUTPUT
    
    print "The total number of matches =", totalMatches
    print ""

main()

'''
Design Question

The program uses one loop to iterate through the list
of search terms, and a variable to store the total number
of matches found (starts at zero). For each search word, 
we use count() to find the number of matches of that search
word in the random word list, and add the result to the total.

Testing Report

REPORT

Test: 1
Input:
***************S***************
apple
orange
pear
***************W***************
apple
apple
apple
orange
pear
banana
lime
orange

Expected Output: [6]
Actual Output: [6]
Result:Pass
'''