/**
 * Given a dictionary containing players scores, return the average score of all the players.
 *
 * @param playersScores A dictionary where the keys are the player names and the values are lists of scores.
 * @return The average score of all players, rounded to two decimal places.
 */
fun getAverageScore(playersScores: Map<String, List<Int>>): Double {

    var totalSum = 0
    var totalCount = 0

    for (scoresList in playersScores.values) {
        totalSum += scoresList.sum()
        totalCount += scoresList.size
    }

    return (totalSum.toDouble() / totalCount).round(2)
}

fun Double.round(decimals: Int): Double {
    var multiplier = 1.0
    repeat(decimals) { multiplier *= 10 }
    return kotlin.math.round(this * multiplier) / multiplier
}
/**
 * Given a dictionary containing players scores, return the average score of all the players.
 *
 * @param playersScores A dictionary where the keys are the player names and the values are lists of scores.
 * @return The average score of all players, rounded to two decimal places.
 */
fun getAverageScore(playersScores: Map<String, List<Int>>): Double {
/**
 * Given a dictionary containing players scores, return the average score of all the players.
 *
 * @param playersScores A dictionary where the keys are the player names and the values are lists of scores.
 * @return The average score of all players, rounded to two decimal places.
 */
fun getAverageScore(playersScores: Map<String, List<Int>>): Double {

    var totalSum = 0
    var totalCount = 0

    for (scoresList in playersScores.values) {
        totalSum += scoresList.sum()
        totalCount += scoresList.size
    }

    return (totalSum.toDouble() / totalCount).round(2)
}

fun Double.round(decimals: Int): Double {
    var multiplier = 1.0
    repeat(decimals) { multiplier *= 10 }
    return kotlin.math.round(this * multiplier) / multiplier
}