/**
 * This function takes an astronomer's catalog and a searched object as input,
 * and returns a list of objects from the catalog that intersect with the searched object.
 *
 * @param astronomerCatalog A list of objects in the astronomer's catalog.
 * @param searchedObject The object to search for intersections.
 * @return A list of objects that intersect with the searched object.
 */
fun findIntersectingObjects(astronomerCatalog: List<String>, searchedObject: String): List<String> {

    val intersectingObjects = mutableListOf<String>()

    // Finding intersections between objects
    for (obj in astronomerCatalog) {
        if (obj != searchedObject) {
            intersectingObjects.add(obj)
            for (keyword in obj.split(" ").toSet()) {
                if (keyword in searchedObject) {
                    intersectingObjects.add(obj)
                    break
                }
            }
        }
    }

    return intersectingObjects
}

val astronomerCatalog = listOf(
    "Milky Way",
    "Andromeda Galaxy",
    "Orion Nebula",
    "Jupiter",
    "Saturn",
    "Mars",
    "Pluto",
    "Uranus",
    "Neptune"
)

val searchedObject = "Galaxy"

// Find
/**
 * This function takes an astronomer's catalog and a searched object as input,
 * and returns a list of objects from the catalog that intersect with the searched object.
 *
 * @param astronomerCatalog A list of objects in the astronomer's catalog.
 * @param searchedObject The object to search for intersections.
 * @return A list of objects that intersect with the searched object.
 */
fun findIntersectingObjects(astronomerCatalog: List<String>, searchedObject: String): List<String> {
/**
 * This function takes an astronomer's catalog and a searched object as input,
 * and returns a list of objects from the catalog that intersect with the searched object.
 *
 * @param astronomerCatalog A list of objects in the astronomer's catalog.
 * @param searchedObject The object to search for intersections.
 * @return A list of objects that intersect with the searched object.
 */
fun findIntersectingObjects(astronomerCatalog: List<String>, searchedObject: String): List<String> {

    val intersectingObjects = mutableListOf<String>()

    // Finding intersections between objects
    for (obj in astronomerCatalog) {
        if (obj != searchedObject) {
            intersectingObjects.add(obj)
            for (keyword in obj.split(" ").toSet()) {
                if (keyword in searchedObject) {
                    intersectingObjects.add(obj)
                    break
                }
            }
        }
    }

    return intersectingObjects
}

val astronomerCatalog = listOf(
    "Milky Way",
    "Andromeda Galaxy",
    "Orion Nebula",
    "Jupiter",
    "Saturn",
    "Mars",
    "Pluto",
    "Uranus",
    "Neptune"
)

val searchedObject = "Galaxy"

// Find