/**
 * Given two sequences, finds the largest common pattern between them.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return The largest common pattern found.
 */
fun largestCommonPattern(sequence1: String, sequence2: String): String {

    var commonPattern = ""
    var maxLength = 0

    for (i in sequence1.indices) {
        for (j in sequence2.indices) {
            if (sequence1[i] == sequence2[j]) {
                var length = 1
                while (i + length < sequence1.length && j + length < sequence2.length && sequence1[i + length] == sequence2[j + length]) {
                    length++
                }

                if (length > maxLength) {
                    maxLength = length
                    commonPattern = sequence1.substring(i, i + length)
                }
            }
        }
    }

    return commonPattern
}
/**
 * Given two sequences, finds the largest common pattern between them.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return The largest common pattern found.
 */
fun largestCommonPattern(sequence1: String, sequence2: String): String {
/**
 * Given two sequences, finds the largest common pattern between them.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return The largest common pattern found.
 */
fun largestCommonPattern(sequence1: String, sequence2: String): String {

    var commonPattern = ""
    var maxLength = 0

    for (i in sequence1.indices) {
        for (j in sequence2.indices) {
            if (sequence1[i] == sequence2[j]) {
                var length = 1
                while (i + length < sequence1.length && j + length < sequence2.length && sequence1[i + length] == sequence2[j + length]) {
                    length++
                }

                if (length > maxLength) {
                    maxLength = length
                    commonPattern = sequence1.substring(i, i + length)
                }
            }
        }
    }

    return commonPattern
}