I am suppose to implement a version of LCS that does the following I/O:
input: superLCS('cat','car')
output: ['ca#','ca#']
currently, my program works for that, but if the letters are out of place, it doesnt work.
for example, if the input is: superLCS('art','cad'), it outputs, ['###','###']. It should be outputting ['a##','#a#']
code:
def superLCS(s1,s2):
return helper(s1,s2,'','')
def helper(s1,s2,res1,res2): #s1 is string 1, s2 is string 2, res1 is result1, res2 is result2
if s1 == '' or s2 == '': #if either string is empty return the result
return [res1,res2]
if s1[0] == s2[0]: #if they are equal, put their string in the list
res1 += s1[0]
res2 += s1[0]
return helper(s1[1:],s2[1:],res1,res2)
else: #if they arent, add a # to the list
res2 += '#'
res1 += '#'
return helper(s1[1:],s2[1:],res1,res2)