from typing import Counter


def compute_cosine_similarity(words1,words2):

    """
    
    Computes the cosine similarity between two codes
    
    Parameters:
    words1 (List) : List of words for the first code 
    words2 (List) : List of words for the second code
    
    Returns:
    cosine (Float) : Cosine similarity of the two codes
    
    """
    
    # Dictionaries with the words of the code
    val1=Counter(words1)
    val2=Counter(words2)
    
    # List of all the words in the two codes
    words = list(val1.keys() | val2.keys())
    
    # Vectors corresponding to the two codes
    vect1 = [val1.get(word, 0) for word in words]
    vect2 = [val2.get(word, 0) for word in words]

    len1 = sum(v*v for v in vect1) ** 0.5
    len2 = sum(v*v for v in vect2) ** 0.5
    dot = sum(v1*v2 for v1,v2 in zip(vect1, vect2))
    cosine = dot/(len1 * len2)
    
    return cosine