#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb  8 10:03:10 2017

@author: brendontucker
"""

s1 = "zzzz"
s2 = "zzzzzzz"

s1List = list(s1)
s2List = list(s2)
#need to determine relative lengths I think... 
s2List.sort()
s1List.sort()

reference = 0
compare = 0
inCommon = 0
lastFoundPos = 0

length1 = len(s1)
length2 = len(s2)

big = list() #ugh this didn't seem to help 
small = list()

if length1 >= length2:
    big = s1List
    small = s2List
else:
    big = s2List
    small = s1List

while reference < len(big): #len(s1List):
    compare = lastFoundPos #so we don't end up getting a bunch of false positives 
    while compare < len(small): #len(s2List):
        if big[reference] == small[compare]:
            inCommon += 1
            lastFoundPos = compare + 1 #oh, was this the problem right here?
            compare += 1
            reference += 1
        else:
            compare += 1
    if compare >= len(small):
        reference += 1




'''
while reference < len(s1List):
    compare = lastFoundPos #so we don't end up getting a bunch of false positives 
    while compare < len(s2List):
        if s1List[reference] == s2List[compare]:
            inCommon += 1
            lastFoundPos = compare + 1
            reference += 1
            compare += 1
        else:
            compare += 1
    if compare >= len(small):
        reference += 1
'''