/**
 * Given a starting position, an ending position, and a list of positions in between,
 * this function calculates the total distance covered.
 */
fun calculateTotalDistance(start: Int, end: Int, positions: List<Int>): Int {

    var distance = positions[0] - start

    for (i in 0 until positions.size - 1) {
        distance += positions[i + 1] - positions[i]
    }

    distance += end - positions.last()

    return distance
}
/**
 * Given a starting position, an ending position, and a list of positions in between,
 * this function calculates the total distance covered.
 */
fun calculateTotalDistance(start: Int, end: Int, positions: List<Int>): Int {
/**
 * Given a starting position, an ending position, and a list of positions in between,
 * this function calculates the total distance covered.
 */
fun calculateTotalDistance(start: Int, end: Int, positions: List<Int>): Int {

    var distance = positions[0] - start

    for (i in 0 until positions.size - 1) {
        distance += positions[i + 1] - positions[i]
    }

    distance += end - positions.last()

    return distance
}