Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I: fanlc2("human", "chimpanzee")
- O: [4, 'h#man', '#h#m#an###']
- I: fanlc2("human", "chimpanzee")
- O: [4, '#', '#h#']
- def fanlc2(S1, S2):
- if S1 == '' or S2 == '':
- return [0, S1, S2]
- if S1[0] == S2[0]:
- temp = fanlc2(S1[1:], S2[1:])
- return [temp[0]+1, S1[0]+temp[1], S2[0]+temp[2]]
- t1 = fanlc2(S1[1:], S2)
- t2 = fanlc2(S1, S2[1:])
- if t1[0] > t2[0] or t1[0] == t2[0]:
- return [t1[0], '#'+t1[1], t2[1]]
- return [t2[0], t1[1], '#'+t2[1]]
- if t1[0] > t2[0] or t1[0] == t2[0]:
- return [t1[0], '#'+t1[1], t1[2]]
- return [t2[0], t2[1], '#'+t2[2]]
Add Comment
Please, Sign In to add comment