/**
 * Given a list of pairs, each containing two DNA sequences, removes the duplicates based on
 * subtracting the reverse of the second sequence from the first sequence using pair unpacking.
 *
 * @param data The list of pairs containing DNA sequences.
 * @return The list of pairs after removing the duplicates based on subtraction.
 *
 * Example:
 * Input: [('ATCG', 'CGAT'), ('GCAA', 'AAGC'), ('TTGA', 'AGTT'), ('CGTA', 'ATCG'), ('AGAG', 'GAGA')]
 * Output: [('ATCG', 'CGAT'), ('GCAA', 'AAGC'), ('TTGA', 'AGTT')]
 */
fun removeDuplicates(data: List<Pair<String, String>>): List<Pair<String, String>> {

    val seen = mutableSetOf<String>()
    val result = mutableListOf<Pair<String, String>>()
    for ((seq1, seq2) in data) {
        val difference = seq1.mapIndexed { index, char -> char - seq2[seq2.length - 1 - index] }
            .joinToString("") { it.toChar().toString() }
        if (difference !in seen) {
            seen.add(difference)
            result.add(Pair(seq1, seq2))
        }
    }
    return result
}
/**
 * Given a list of pairs, each containing two DNA sequences, removes the duplicates based on
 * subtracting the reverse of the second sequence from the first sequence using pair unpacking.
 *
 * @param data The list of pairs containing DNA sequences.
 * @return The list of pairs after removing the duplicates based on subtraction.
 *
 * Example:
 * Input: [('ATCG', 'CGAT'), ('GCAA', 'AAGC'), ('TTGA', 'AGTT'), ('CGTA', 'ATCG'), ('AGAG', 'GAGA')]
 * Output: [('ATCG', 'CGAT'), ('GCAA', 'AAGC'), ('TTGA', 'AGTT')]
 */
fun removeDuplicates(data: List<Pair<String, String>>): List<Pair<String, String>> {
/**
 * Given a list of pairs, each containing two DNA sequences, removes the duplicates based on
 * subtracting the reverse of the second sequence from the first sequence using pair unpacking.
 *
 * @param data The list of pairs containing DNA sequences.
 * @return The list of pairs after removing the duplicates based on subtraction.
 *
 * Example:
 * Input: [('ATCG', 'CGAT'), ('GCAA', 'AAGC'), ('TTGA', 'AGTT'), ('CGTA', 'ATCG'), ('AGAG', 'GAGA')]
 * Output: [('ATCG', 'CGAT'), ('GCAA', 'AAGC'), ('TTGA', 'AGTT')]
 */
fun removeDuplicates(data: List<Pair<String, String>>): List<Pair<String, String>> {

    val seen = mutableSetOf<String>()
    val result = mutableListOf<Pair<String, String>>()
    for ((seq1, seq2) in data) {
        val difference = seq1.mapIndexed { index, char -> char - seq2[seq2.length - 1 - index] }
            .joinToString("") { it.toChar().toString() }
        if (difference !in seen) {
            seen.add(difference)
            result.add(Pair(seq1, seq2))
        }
    }
    return result
}