"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write a function that takes two sequences and returns the longest common substring. A substring is a contiguous portion of a string. For example:\n",
"\n",
"Substrings of `ATGCATAT`:\n",
"\n",
" TGCA\n",
" T\n",
" TAT\n",
" \n",
"Not substrings of `ATGCATAT`:\n",
"\n",
" AGCA # Skipped T\n",
" CCATA # Added another C\n",
" Hello, world. # Has nothing to do with the input sequence\n",
" \n",
"There may be more than one longest common substring; you only need to return one of them.\n",
"\n",
"The call signature of the function should be\n",
"\n",
"```python\n",
"longest_common_substring(s1, s2)\n",
"```\n",
"\n",
"Here are some return values you should get.\n",
"\n",
"|Function call|Result |\n",
"|:---|---:|\n",
"|`longest_common_substring('ATGC', 'ATGCA')` | `'ATGC'`|\n",
"|`longest_common_substring('GATGCCATGCA', 'ATGCC')` | `'ATGCC'`|\n",
"|`longest_common_substring('ACGTGGAAAGCCA', 'GTACACACGTTTTGAGAGACAC') `|`'ACGT'`|"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}