/**
 * Calculate the number of laps an athlete needs to complete in order to reach the target distance.
 *
 * @param athlete The name of the athlete.
 * @param targetDistance The target distance in kilometers.
 * @return The number of laps the athlete needs to complete.
 * @throws IllegalArgumentException If targetDistance is less than or equal to 0.
 */
fun trackDistance(athlete: String, targetDistance: Double): Int {

    if (targetDistance <= 0) {
        throw IllegalArgumentException("Target distance must be greater than 0.")
    }

    val lapDistances = setOf(1.0, 1.5, 2.0, 2.5, 3.0)  // Distances of each lap in kilometers
    var totalDistance = 0.0
    var lapsCompleted = 0

    while (totalDistance < targetDistance) {
        // Choose a random lap distance from the set
        val lapDistance = lapDistances.random()

        // Increase the total distance and increment the laps completed
        totalDistance += lapDistance
        lapsCompleted++
    }

    return lapsCompleted
}
/**
 * Calculate the number of laps an athlete needs to complete in order to reach the target distance.
 *
 * @param athlete The name of the athlete.
 * @param targetDistance The target distance in kilometers.
 * @return The number of laps the athlete needs to complete.
 * @throws IllegalArgumentException If targetDistance is less than or equal to 0.
 */
fun trackDistance(athlete: String, targetDistance: Double): Int {
/**
 * Calculate the number of laps an athlete needs to complete in order to reach the target distance.
 *
 * @param athlete The name of the athlete.
 * @param targetDistance The target distance in kilometers.
 * @return The number of laps the athlete needs to complete.
 * @throws IllegalArgumentException If targetDistance is less than or equal to 0.
 */
fun trackDistance(athlete: String, targetDistance: Double): Int {

    if (targetDistance <= 0) {
        throw IllegalArgumentException("Target distance must be greater than 0.")
    }

    val lapDistances = setOf(1.0, 1.5, 2.0, 2.5, 3.0)  // Distances of each lap in kilometers
    var totalDistance = 0.0
    var lapsCompleted = 0

    while (totalDistance < targetDistance) {
        // Choose a random lap distance from the set
        val lapDistance = lapDistances.random()

        // Increase the total distance and increment the laps completed
        totalDistance += lapDistance
        lapsCompleted++
    }

    return lapsCompleted
}