@anonymous/

ElectricAchingAnkole

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from time import time

def LCS(X, Y):
    if len(X) == 0 or len(Y) == 0:
        res = []
    elif X[-1] == Y[-1]:
        res = LCS(X[:-1], Y[:-1]) + [X[-1]]
    else:
        res = longest(LCS(X, Y[:-1]), LCS(X[:-1], Y))
    return res

def longest(X, Y):
    if len(X) > len(Y):
        return X
    else:
        return Y

start = time()
print("".join(LCS("arn. schwarzenegger", "ar. chuarcheneger")))
print("Time elapsed: %.4fs" % (time()- start))