Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Dynamursion solution in Clear category for DNA Common Sequence by veky
import functools
@functools.lru_cache(maxsize=None)
def cset(X, Y):
if not (X and Y): return {""}
if X[0] == Y[0]: return {X[0] + seq for seq in cset(X[1:], Y[1:])}
seqs = cset(X, Y[1:]) | cset(X[1:], Y)
return {seq for seq in seqs if len(seq) == max(map(len, seqs))}
common = lambda *args: ",".join(sorted(cset(*args)))
Dec. 27, 2014
Comments: