/**
 * The police officer's name is given as a string and the tuple of words contains different words.
 * Your task is to iterate over each character of the police officer's name and access the corresponding
 * element from the tuple using the index of the character.
 *
 * For example, if the police officer's name is 'John' and the tuple of words is ('Hello', 'Python', 'World'),
 * you need to access the first character 'J' and print the corresponding word at index 9 in the tuple,
 * then access 'o' and print the corresponding word at index 15, and so on. The program should print the
 * accessed words for each character.
 *
 * Your solution should work for any police officer's name and any tuple of words.
 *
 * Note: The index for the characters in the police officer's name should start from 1, not 0.
 */
fun iterateCharactersAndAccessTupleElements(policeOfficerName: String, tupleOfWords: List<String>) {

    for ((index, character) in policeOfficerName.withIndex()) {
        println("Character: $character")

        try {
            println("Accessed Word: ${tupleOfWords[character.toInt() % tupleOfWords.size]}")
        } catch (e: IndexOutOfBoundsException) {
            println("Index out of bounds")
        }
    }
}
/**
 * The police officer's name is given as a string and the tuple of words contains different words.
 * Your task is to iterate over each character of the police officer's name and access the corresponding
 * element from the tuple using the index of the character.
 *
 * For example, if the police officer's name is 'John' and the tuple of words is ('Hello', 'Python', 'World'),
 * you need to access the first character 'J' and print the corresponding word at index 9 in the tuple,
 * then access 'o' and print the corresponding word at index 15, and so on. The program should print the
 * accessed words for each character.
 *
 * Your solution should work for any police officer's name and any tuple of words.
 *
 * Note: The index for the characters in the police officer's name should start from 1, not 0.
 */
fun iterateCharactersAndAccessTupleElements(policeOfficerName: String, tupleOfWords: List<String>) {
/**
 * The police officer's name is given as a string and the tuple of words contains different words.
 * Your task is to iterate over each character of the police officer's name and access the corresponding
 * element from the tuple using the index of the character.
 *
 * For example, if the police officer's name is 'John' and the tuple of words is ('Hello', 'Python', 'World'),
 * you need to access the first character 'J' and print the corresponding word at index 9 in the tuple,
 * then access 'o' and print the corresponding word at index 15, and so on. The program should print the
 * accessed words for each character.
 *
 * Your solution should work for any police officer's name and any tuple of words.
 *
 * Note: The index for the characters in the police officer's name should start from 1, not 0.
 */
fun iterateCharactersAndAccessTupleElements(policeOfficerName: String, tupleOfWords: List<String>) {

    for ((index, character) in policeOfficerName.withIndex()) {
        println("Character: $character")

        try {
            println("Accessed Word: ${tupleOfWords[character.toInt() % tupleOfWords.size]}")
        } catch (e: IndexOutOfBoundsException) {
            println("Index out of bounds")
        }
    }
}