/**
 * This function calculates the slope of a road using the range function and left/right shift operators.
 *
 * @param lengthRange The range of length values for the road.
 * @param shiftOperator The direction of the shift operator, either 'left' or 'right'.
 * @return The slope of the road.
 */
fun calculateSlope(lengthRange: IntRange, shiftOperator: String): Float {

    val roadElevations = mutableListOf<Int>()

    for (length in lengthRange) {
        var elev = 0
        when (shiftOperator) {
            "left" -> elev = length shl 2
            "right" -> elev = length shr 2
        }
        roadElevations.add(elev)
    }

    val elevationChange = (1 until roadElevations.size).map { roadElevations[it] - roadElevations[it - 1] }
    val roadSlope = elevationChange.sum() / (roadElevations.size - 1).toFloat()

    return roadSlope
}
/**
 * This function calculates the slope of a road using the range function and left/right shift operators.
 *
 * @param lengthRange The range of length values for the road.
 * @param shiftOperator The direction of the shift operator, either 'left' or 'right'.
 * @return The slope of the road.
 */
fun calculateSlope(lengthRange: IntRange, shiftOperator: String): Float {
/**
 * This function calculates the slope of a road using the range function and left/right shift operators.
 *
 * @param lengthRange The range of length values for the road.
 * @param shiftOperator The direction of the shift operator, either 'left' or 'right'.
 * @return The slope of the road.
 */
fun calculateSlope(lengthRange: IntRange, shiftOperator: String): Float {

    val roadElevations = mutableListOf<Int>()

    for (length in lengthRange) {
        var elev = 0
        when (shiftOperator) {
            "left" -> elev = length shl 2
            "right" -> elev = length shr 2
        }
        roadElevations.add(elev)
    }

    val elevationChange = (1 until roadElevations.size).map { roadElevations[it] - roadElevations[it - 1] }
    val roadSlope = elevationChange.sum() / (roadElevations.size - 1).toFloat()

    return roadSlope
}