/**
 * This function takes in a tuple of search terms and a tuple of criminals
 * and returns a list containing the locations where the criminals can be found.
 * The search terms can be single search words or multiple words separated by OR operator.
 * The function uses nested tuples to match the search terms with the criminals' profiles.
 *
 * @param searchTerms A tuple of search terms provided by the Police Officer.
 * @param criminals A tuple of criminals' profiles including their names, ages, and last known locations.
 * @return A list containing the locations where the criminals can be found.
 */
fun findCriminalsLocations(searchTerms: List<String>, criminals: List<Triple<String, Int, String>>): List<String> {

    val locations = mutableListOf<String>()

    for (searchTerm in searchTerms) {
        val searchWords = searchTerm.split(" OR ")
        for (criminal in criminals) {
            var profileMatched = true
            for (word in searchWords) {
                if (word.toUpperCase() !in criminal.first.toUpperCase() && word.toUpperCase() !in criminal.third.toUpperCase()) {
                    profileMatched = false
                    break
                }
            }
            if (profileMatched) {
                locations.add(criminal.third)
            }
        }
    }

    return locations
}

// Example usage
/**
 * This function takes in a tuple of search terms and a tuple of criminals
 * and returns a list containing the locations where the criminals can be found.
 * The search terms can be single search words or multiple words separated by OR operator.
 * The function uses nested tuples to match the search terms with the criminals' profiles.
 *
 * @param searchTerms A tuple of search terms provided by the Police Officer.
 * @param criminals A tuple of criminals' profiles including their names, ages, and last known locations.
 * @return A list containing the locations where the criminals can be found.
 */
fun findCriminalsLocations(searchTerms: List<String>, criminals: List<Triple<String, Int, String>>): List<String> {
/**
 * This function takes in a tuple of search terms and a tuple of criminals
 * and returns a list containing the locations where the criminals can be found.
 * The search terms can be single search words or multiple words separated by OR operator.
 * The function uses nested tuples to match the search terms with the criminals' profiles.
 *
 * @param searchTerms A tuple of search terms provided by the Police Officer.
 * @param criminals A tuple of criminals' profiles including their names, ages, and last known locations.
 * @return A list containing the locations where the criminals can be found.
 */
fun findCriminalsLocations(searchTerms: List<String>, criminals: List<Triple<String, Int, String>>): List<String> {

    val locations = mutableListOf<String>()

    for (searchTerm in searchTerms) {
        val searchWords = searchTerm.split(" OR ")
        for (criminal in criminals) {
            var profileMatched = true
            for (word in searchWords) {
                if (word.toUpperCase() !in criminal.first.toUpperCase() && word.toUpperCase() !in criminal.third.toUpperCase()) {
                    profileMatched = false
                    break
                }
            }
            if (profileMatched) {
                locations.add(criminal.third)
            }
        }
    }

    return locations
}

// Example usage