/**
 * Given the area of a region and the step size, calculate the volumes of a series
 * of grids within the region using the step parameter to incrementally iterate over
 * the region.
 *
 * @param area The total area of the region.
 * @param step The size of each grid within the region.
 * @return A list of calculated volumes of each grid within the region.
 *
 * Example:
 * calculateGridVolumes(100.0, 5.0) returns [25.0, 25.0, 25.0, 25.0]
 * calculateGridVolumes(100.0, 10.0) returns [100.0]
 */
fun calculateGridVolumes(area: Double, step: Double): List<Double> {

    val volumes = mutableListOf<Double>()
    var x = 0.0
    while (x < area) {
        val volume = if (x + step > area) {
            val remainder = area - x
            remainder * step
        } else {
            step * step
        }
        volumes.add(volume)
        x += step
    }
    return volumes
}
/**
 * Given the area of a region and the step size, calculate the volumes of a series
 * of grids within the region using the step parameter to incrementally iterate over
 * the region.
 *
 * @param area The total area of the region.
 * @param step The size of each grid within the region.
 * @return A list of calculated volumes of each grid within the region.
 *
 * Example:
 * calculateGridVolumes(100.0, 5.0) returns [25.0, 25.0, 25.0, 25.0]
 * calculateGridVolumes(100.0, 10.0) returns [100.0]
 */
fun calculateGridVolumes(area: Double, step: Double): List<Double> {
/**
 * Given the area of a region and the step size, calculate the volumes of a series
 * of grids within the region using the step parameter to incrementally iterate over
 * the region.
 *
 * @param area The total area of the region.
 * @param step The size of each grid within the region.
 * @return A list of calculated volumes of each grid within the region.
 *
 * Example:
 * calculateGridVolumes(100.0, 5.0) returns [25.0, 25.0, 25.0, 25.0]
 * calculateGridVolumes(100.0, 10.0) returns [100.0]
 */
fun calculateGridVolumes(area: Double, step: Double): List<Double> {

    val volumes = mutableListOf<Double>()
    var x = 0.0
    while (x < area) {
        val volume = if (x + step > area) {
            val remainder = area - x
            remainder * step
        } else {
            step * step
        }
        volumes.add(volume)
        x += step
    }
    return volumes
}