Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6-liner: compact solution in Creative category for DNA Common Sequence by przemyslaw.daniel
from functools import lru_cache
@lru_cache(maxsize=None)
def common(a, b):
c = set.union(*[{k+x for x in common(a[a.find(k)+1:], b[b.find(k)+1:]).split(',')}
for k in "TCGA" if k in a and k in b]) if set(a).intersection(b) else ""
return ','.join(sorted({x for x in c if len(x) == max([len(x) for x in c])}))
April 1, 2017
Comments: