/**
 * This function extracts the codons from a given DNA sequence within a specified range.
 *
 * @param dnaSequence The DNA sequence from which codons will be extracted.
 * @param start The starting index of the range from where to extract codons.
 * @param stop The ending index of the range up to which codons should be extracted.
 * @return A list of codons extracted from the specified range.
 */
fun extractCodons(dnaSequence: String, start: Int, stop: Int): List<String> {

    // Checking if the start and stop indices fall within the valid range
    if (start < 0 || start >= dnaSequence.length || stop <= start || stop > dnaSequence.length) {
        throw IllegalArgumentException("Invalid start or stop index.")
    }

    val codons = mutableListOf<String>()
    for (i in start until stop - 2 step 3) {
        val codon = dnaSequence.substring(i, i + 3)
        codons.add(codon)
    }

    return codons
}
/**
 * This function extracts the codons from a given DNA sequence within a specified range.
 *
 * @param dnaSequence The DNA sequence from which codons will be extracted.
 * @param start The starting index of the range from where to extract codons.
 * @param stop The ending index of the range up to which codons should be extracted.
 * @return A list of codons extracted from the specified range.
 */
fun extractCodons(dnaSequence: String, start: Int, stop: Int): List<String> {
/**
 * This function extracts the codons from a given DNA sequence within a specified range.
 *
 * @param dnaSequence The DNA sequence from which codons will be extracted.
 * @param start The starting index of the range from where to extract codons.
 * @param stop The ending index of the range up to which codons should be extracted.
 * @return A list of codons extracted from the specified range.
 */
fun extractCodons(dnaSequence: String, start: Int, stop: Int): List<String> {

    // Checking if the start and stop indices fall within the valid range
    if (start < 0 || start >= dnaSequence.length || stop <= start || stop > dnaSequence.length) {
        throw IllegalArgumentException("Invalid start or stop index.")
    }

    val codons = mutableListOf<String>()
    for (i in start until stop - 2 step 3) {
        val codon = dnaSequence.substring(i, i + 3)
        codons.add(codon)
    }

    return codons
}