/**
 * Implement a function that returns a range of numbers between the start and stop parameters,
 * with each number rounded to a specific precision level.
 *
 * @param start The starting number of the range (inclusive).
 * @param stop The ending number of the range (exclusive).
 * @param precision The number of decimal places to round each number to.
 * @return A list of rounded numbers within the specified range.
 *
 * Example:
 * roundAndRange(0.5, 3.2, 2) -> [0.5, 0.51, ..., 3.19]
 */
fun roundAndRange(start: Double, stop: Double, precision: Int): List<Double> {

    val roundedRange = mutableListOf<Double>()
    var current = start

    // Calculate the number of iterations required to reach the stop value with the desired precision
    val iterations = ((stop - start) * Math.pow(10.0, precision.toDouble())).toInt()

    // Perform the rounding and append each number to the result list
    repeat(iterations) {
        roundedRange.add(current.roundTo(precision))
        current += Math.pow(10.0, -precision.toDouble())
    }

    return roundedRange
}

fun Double.roundTo(precision: Int): Double {
    val scale = Math.pow(10.0, precision.toDouble())
    return Math.round(this * scale) / scale
}
/**
 * Implement a function that returns a range of numbers between the start and stop parameters,
 * with each number rounded to a specific precision level.
 *
 * @param start The starting number of the range (inclusive).
 * @param stop The ending number of the range (exclusive).
 * @param precision The number of decimal places to round each number to.
 * @return A list of rounded numbers within the specified range.
 *
 * Example:
 * roundAndRange(0.5, 3.2, 2) -> [0.5, 0.51, ..., 3.19]
 */
fun roundAndRange(start: Double, stop: Double, precision: Int): List<Double> {
/**
 * Implement a function that returns a range of numbers between the start and stop parameters,
 * with each number rounded to a specific precision level.
 *
 * @param start The starting number of the range (inclusive).
 * @param stop The ending number of the range (exclusive).
 * @param precision The number of decimal places to round each number to.
 * @return A list of rounded numbers within the specified range.
 *
 * Example:
 * roundAndRange(0.5, 3.2, 2) -> [0.5, 0.51, ..., 3.19]
 */
fun roundAndRange(start: Double, stop: Double, precision: Int): List<Double> {

    val roundedRange = mutableListOf<Double>()
    var current = start

    // Calculate the number of iterations required to reach the stop value with the desired precision
    val iterations = ((stop - start) * Math.pow(10.0, precision.toDouble())).toInt()

    // Perform the rounding and append each number to the result list
    repeat(iterations) {
        roundedRange.add(current.roundTo(precision))
        current += Math.pow(10.0, -precision.toDouble())
    }

    return roundedRange
}

fun Double.roundTo(precision: Int): Double {
    val scale = Math.pow(10.0, precision.toDouble())
    return Math.round(this * scale) / scale
}