/**
 * This function compares two lists representing treasures found by an archaeologist.
 * The function returns a message indicating the relative value of the treasures, and handles any errors that may occur.
 *
 * @param treasure1 The first list representing the first treasure.
 * @param treasure2 The second list representing the second treasure.
 * @return A message indicating the relative value of the treasures.
 * @throws IllegalArgumentException If the input lists do not have the same number of elements.
 * @throws IllegalArgumentException If the input lists contain non-integer values.
 */
fun compareTreasures(treasure1: List<Int>, treasure2: List<Int>): String {

    if (treasure1.size != treasure2.size) {
        throw IllegalArgumentException("The input lists must have the same number of elements.")
    }

    if (treasure1.any { it !is Int } || treasure2.any { it !is Int }) {
        throw IllegalArgumentException("The input lists must contain only integer values.")
    }

    val treasure1Value = treasure1.sum()
    val treasure2Value = treasure2.sum()

    return when {
        treasure1Value > treasure2Value -> "The first treasure is more valuable than the second treasure."
        treasure1Value < treasure2Value -> "The second treasure is more valuable than the first treasure."
        else -> "Both treasures have the same value."
    }
}
/**
 * This function compares two lists representing treasures found by an archaeologist.
 * The function returns a message indicating the relative value of the treasures, and handles any errors that may occur.
 *
 * @param treasure1 The first list representing the first treasure.
 * @param treasure2 The second list representing the second treasure.
 * @return A message indicating the relative value of the treasures.
 * @throws IllegalArgumentException If the input lists do not have the same number of elements.
 * @throws IllegalArgumentException If the input lists contain non-integer values.
 */
fun compareTreasures(treasure1: List<Int>, treasure2: List<Int>): String {
/**
 * This function compares two lists representing treasures found by an archaeologist.
 * The function returns a message indicating the relative value of the treasures, and handles any errors that may occur.
 *
 * @param treasure1 The first list representing the first treasure.
 * @param treasure2 The second list representing the second treasure.
 * @return A message indicating the relative value of the treasures.
 * @throws IllegalArgumentException If the input lists do not have the same number of elements.
 * @throws IllegalArgumentException If the input lists contain non-integer values.
 */
fun compareTreasures(treasure1: List<Int>, treasure2: List<Int>): String {

    if (treasure1.size != treasure2.size) {
        throw IllegalArgumentException("The input lists must have the same number of elements.")
    }

    if (treasure1.any { it !is Int } || treasure2.any { it !is Int }) {
        throw IllegalArgumentException("The input lists must contain only integer values.")
    }

    val treasure1Value = treasure1.sum()
    val treasure2Value = treasure2.sum()

    return when {
        treasure1Value > treasure2Value -> "The first treasure is more valuable than the second treasure."
        treasure1Value < treasure2Value -> "The second treasure is more valuable than the first treasure."
        else -> "Both treasures have the same value."
    }
}