/**
 * Given a dictionary mapping keys to floating-point values and a target value, this function finds the key in the dictionary whose corresponding value is the closest to the target value.
 *
 * @param dictionary A dictionary mapping keys to floating-point values.
 * @param value The target value to find the closest value to.
 * @return The key in the dictionary whose corresponding value is the closest to the target value.
 */
fun findClosestValue(dictionary: Map<String, Double>, value: Double): String? {

    var closestKey: String? = null
    var closestDifference: Double? = null

    for ((key, dictValue) in dictionary) {
        val difference = Math.abs(dictValue - value)
        if (closestDifference == null || difference < closestDifference) {
            closestKey = key
            closestDifference = difference
        }
    }

    return closestKey
}
/**
 * Given a dictionary mapping keys to floating-point values and a target value, this function finds the key in the dictionary whose corresponding value is the closest to the target value.
 *
 * @param dictionary A dictionary mapping keys to floating-point values.
 * @param value The target value to find the closest value to.
 * @return The key in the dictionary whose corresponding value is the closest to the target value.
 */
fun findClosestValue(dictionary: Map<String, Double>, value: Double): String? {
/**
 * Given a dictionary mapping keys to floating-point values and a target value, this function finds the key in the dictionary whose corresponding value is the closest to the target value.
 *
 * @param dictionary A dictionary mapping keys to floating-point values.
 * @param value The target value to find the closest value to.
 * @return The key in the dictionary whose corresponding value is the closest to the target value.
 */
fun findClosestValue(dictionary: Map<String, Double>, value: Double): String? {

    var closestKey: String? = null
    var closestDifference: Double? = null

    for ((key, dictValue) in dictionary) {
        val difference = Math.abs(dictValue - value)
        if (closestDifference == null || difference < closestDifference) {
            closestKey = key
            closestDifference = difference
        }
    }

    return closestKey
}