/**
 * Concatenates a list of strings using a specified logical operator.
 * The logical operator determines the concatenation order based on the precedence of logical operators in Python.
 *
 * @param strings A list of strings to be concatenated.
 * @param operator The logical operator to determine concatenation order.
 *                 Valid options are "and", "or", "not", and "xor".
 * @return The concatenated string.
 * @throws IllegalArgumentException If an invalid logical operator is provided.
 *
 * Example:
 * concatenateStrings(listOf("Hello", "World", "from"), "and") returns "fromWorldHello"
 * concatenateStrings(listOf("Hello", "World", "from"), "or") returns "Hello"
 * concatenateStrings(listOf("Hello", "World", "from"), "not") throws IllegalArgumentException
 */
fun concatenateStrings(strings: List<String>, operator: String): String {

    return when (operator) {
        "and" -> strings.last() + strings[1] + strings[0]
        "or" -> strings[0]
        else -> throw IllegalArgumentException("Invalid logical operator! Valid options are 'and', 'or', 'not', 'xor'.")
    }
}
/**
 * Concatenates a list of strings using a specified logical operator.
 * The logical operator determines the concatenation order based on the precedence of logical operators in Python.
 *
 * @param strings A list of strings to be concatenated.
 * @param operator The logical operator to determine concatenation order.
 *                 Valid options are "and", "or", "not", and "xor".
 * @return The concatenated string.
 * @throws IllegalArgumentException If an invalid logical operator is provided.
 *
 * Example:
 * concatenateStrings(listOf("Hello", "World", "from"), "and") returns "fromWorldHello"
 * concatenateStrings(listOf("Hello", "World", "from"), "or") returns "Hello"
 * concatenateStrings(listOf("Hello", "World", "from"), "not") throws IllegalArgumentException
 */
fun concatenateStrings(strings: List<String>, operator: String): String {
/**
 * Concatenates a list of strings using a specified logical operator.
 * The logical operator determines the concatenation order based on the precedence of logical operators in Python.
 *
 * @param strings A list of strings to be concatenated.
 * @param operator The logical operator to determine concatenation order.
 *                 Valid options are "and", "or", "not", and "xor".
 * @return The concatenated string.
 * @throws IllegalArgumentException If an invalid logical operator is provided.
 *
 * Example:
 * concatenateStrings(listOf("Hello", "World", "from"), "and") returns "fromWorldHello"
 * concatenateStrings(listOf("Hello", "World", "from"), "or") returns "Hello"
 * concatenateStrings(listOf("Hello", "World", "from"), "not") throws IllegalArgumentException
 */
fun concatenateStrings(strings: List<String>, operator: String): String {

    return when (operator) {
        "and" -> strings.last() + strings[1] + strings[0]
        "or" -> strings[0]
        else -> throw IllegalArgumentException("Invalid logical operator! Valid options are 'and', 'or', 'not', 'xor'.")
    }
}