# Rosalind: BA5C — Find a Longest Common Subsequence of Two Strings # https://rosalind.info/problems/ba5c/ # # Given: Two strings. # Return: A longest common subsequence. let s = "AACCTTGG" let t = "ACACTGTGA" # lcs is a builtin. There is generally more than one longest common # subsequence — the sample shows AACTGG, this returns another of the same # length — so the assertion checks the length and that it really is a # subsequence of both, which is what the problem asks for. let common = lcs(s, t) println("Result: " + common + " (length " + str(len(common)) + ")") println("Expected: AACTGG, or any other subsequence of length 6") fn test_ba5c_longest_common_subsequence() { assert len(common) == 6, "BA5C: expected length 6, got " + str(len(common)) assert is_subsequence(common, s), "BA5C: not a subsequence of s" assert is_subsequence(common, t), "BA5C: not a subsequence of t" assert len(lcs("AACTGG", t)) == 6, "BA5C: the sample answer should also be length 6" }