/**
 * Given a string and a list of indices, this function should return the concatenated result of the characters at the
 * specified indices.
 *
 * @param text A string containing any characters.
 * @param indices A list of integers representing the indices at which the characters should be extracted.
 * @return A string containing the characters extracted from 'text' at the specified indices, concatenated together.
 */
fun concatenateAndIndex(text: String, indices: List<Int>): String {

    var result = ""
    for (index in indices) {
        if (index in 0 until text.length) {
            result += text[index]
        }
    }
    return result
}

// Example usage
/**
 * Given a string and a list of indices, this function should return the concatenated result of the characters at the
 * specified indices.
 *
 * @param text A string containing any characters.
 * @param indices A list of integers representing the indices at which the characters should be extracted.
 * @return A string containing the characters extracted from 'text' at the specified indices, concatenated together.
 */
fun concatenateAndIndex(text: String, indices: List<Int>): String {
/**
 * Given a string and a list of indices, this function should return the concatenated result of the characters at the
 * specified indices.
 *
 * @param text A string containing any characters.
 * @param indices A list of integers representing the indices at which the characters should be extracted.
 * @return A string containing the characters extracted from 'text' at the specified indices, concatenated together.
 */
fun concatenateAndIndex(text: String, indices: List<Int>): String {

    var result = ""
    for (index in indices) {
        if (index in 0 until text.length) {
            result += text[index]
        }
    }
    return result
}

// Example usage