/**
 * Given a list of floating-point numbers, return a list of all the pairs of numbers that are approximately equal within a
 * given epsilon value.
 *
 * @param numbers A list of floating-point numbers.
 * @param epsilon The maximum difference allowed between two numbers to be considered approximately equal.
 * @return A list of pairs representing the numbers that are approximately equal within the given epsilon value.
 *
 * Example:
 * findCommonNumbers(listOf(1.123, 2.345, 3.456, 2.121, 3.121), 0.01)
 * Output: [(1.123, 2.121), (2.345, 2.121), (2.121, 3.121)]
 */
fun findCommonNumbers(numbers: List<Double>, epsilon: Double): List<Pair<Double, Double>> {

    val commonNumbers = mutableListOf<Pair<Double, Double>>()

    for (i in numbers.indices) {
        for (j in i + 1 until numbers.size) {
            if (Math.abs(numbers[i] - numbers[j]) < epsilon) {
                commonNumbers.add(Pair(numbers[i], numbers[j]))
            }
        }
    }

    return commonNumbers
}
/**
 * Given a list of floating-point numbers, return a list of all the pairs of numbers that are approximately equal within a
 * given epsilon value.
 *
 * @param numbers A list of floating-point numbers.
 * @param epsilon The maximum difference allowed between two numbers to be considered approximately equal.
 * @return A list of pairs representing the numbers that are approximately equal within the given epsilon value.
 *
 * Example:
 * findCommonNumbers(listOf(1.123, 2.345, 3.456, 2.121, 3.121), 0.01)
 * Output: [(1.123, 2.121), (2.345, 2.121), (2.121, 3.121)]
 */
fun findCommonNumbers(numbers: List<Double>, epsilon: Double): List<Pair<Double, Double>> {
/**
 * Given a list of floating-point numbers, return a list of all the pairs of numbers that are approximately equal within a
 * given epsilon value.
 *
 * @param numbers A list of floating-point numbers.
 * @param epsilon The maximum difference allowed between two numbers to be considered approximately equal.
 * @return A list of pairs representing the numbers that are approximately equal within the given epsilon value.
 *
 * Example:
 * findCommonNumbers(listOf(1.123, 2.345, 3.456, 2.121, 3.121), 0.01)
 * Output: [(1.123, 2.121), (2.345, 2.121), (2.121, 3.121)]
 */
fun findCommonNumbers(numbers: List<Double>, epsilon: Double): List<Pair<Double, Double>> {

    val commonNumbers = mutableListOf<Pair<Double, Double>>()

    for (i in numbers.indices) {
        for (j in i + 1 until numbers.size) {
            if (Math.abs(numbers[i] - numbers[j]) < epsilon) {
                commonNumbers.add(Pair(numbers[i], numbers[j]))
            }
        }
    }

    return commonNumbers
}