'''
Created on Mar 22, 2017
@author: rodger

This is similar to the popular problem we looked at before, but now we 
will use dictionaries to solve the problem. 

Instead of reading from a data file, I've already put the data into a list.
This will allow you to trace the program in PythonTutor if you want to see how 
the dictionary/map is visualized.

'''

        
def printFirstWithLasts(namemap):
    print "Print Unique First Names with all Last Names"      
    #TODO:


    
def mapNameToNumberLastNames(data):
    '''
    Create countmap, a map of first names to its number of occurrences
    The parameter data is a list of lists where each list is two  
    strings representing the first and last name of a person.         
    '''
    #todo:
    countmap = {}
    
    return countmap


            
def  mapNameToLastNames(data):
    '''
    Create namemap, a map of first names to list of corresponding last names 
    The parameter data is a list of lists where each list is two  
    strings representing the first and last name of a person.    
    '''  
    #todo:
    namemap = {}
    
    return namemap



def  mapNameToSetLastNames(data):
    '''
    Create namemap, a map of first names to set of corresponding last names 
    The parameter data is a list of lists where each list is two  
    strings representing the first and last name of a person.    
    '''  
    namesetmap = {}
    
    return namesetmap


def main():
    '''
    This is popular problem without files and using a dictionary/map

    namelist is defined below instead of reading in the data from a file.
    This will allow you to see what is happening in PythonTutor. 
    '''
    namelist = [['Susan', 'Smith'], ['Jackie', 'Long'], ['Mary', 'White'], ['Susan', 'Brandt'], ['Jackie', 'Johnson'], ['Susan', 'Rodger'], ['Mary', 'Rodger'], ['Eric', 'Long'], ['Susan', 'Crackers'], ['Mary', 'Velios'], ['Jack', 'Frost'], ['Eric', 'Lund'], ['Susan', 'Krishnan'], ['Bala', 'Krishnamurthy'], ['Craig', 'Wills'], ['Carol', 'Wills'], ['Craig', 'Partridge'], ['Craig', 'Kim'], ['Craig', 'Matthews'], ['Bala', 'Yavatkar'], ['Susan', 'Perilous'], ['Mary', 'Evans'], ['Kara', 'Krishnan'], ['Susan', 'Smithereens']]
    print "namelist is: ", namelist 
    print


    countmap = mapNameToNumberLastNames(namelist)
    print "countmap is:", countmap
    print
    

    namemap = mapNameToLastNames(namelist)
    print "namemap is:", namemap
    print
    
    namesetmap = mapNameToSetLastNames(namelist)
    print "namesetmap is:", namesetmap 
    print   
        
    #print First names with all the last names
    printFirstWithLasts(namemap)
    print
    
    #TODO: Compute maxnum    
    maxnum = 0
    print "maximum number of last names is", maxnum
    
    print
    maxname = ""
    print "first name with most last names is:", maxname
    #TODO:
 
 
 
    
if __name__ == "__main__":
    main() 
        
     
