/**
 * Given two lists p1 and p2 representing the names of planets,
 * return a list of planets that are present in both lists.
 *
 * @param p1 List of planet names
 * @param p2 List of planet names
 * @return List of planets that are present in both lists
 *
 * Example:
 * findPlanets(listOf("Earth", "Mars", "Neptune"), listOf("Jupiter", "Pluto", "Mars")) // Output: ["Mars"]
 */
fun findPlanets(p1: List<String>, p2: List<String>): List<String> {

    // Retrieve the planets that are common to both lists using set intersection
    val commonPlanets = p1.intersect(p2)

    // Sort the resulting planets and return as a list
    return commonPlanets.sorted()
}
/**
 * Given two lists p1 and p2 representing the names of planets,
 * return a list of planets that are present in both lists.
 *
 * @param p1 List of planet names
 * @param p2 List of planet names
 * @return List of planets that are present in both lists
 *
 * Example:
 * findPlanets(listOf("Earth", "Mars", "Neptune"), listOf("Jupiter", "Pluto", "Mars")) // Output: ["Mars"]
 */
fun findPlanets(p1: List<String>, p2: List<String>): List<String> {
/**
 * Given two lists p1 and p2 representing the names of planets,
 * return a list of planets that are present in both lists.
 *
 * @param p1 List of planet names
 * @param p2 List of planet names
 * @return List of planets that are present in both lists
 *
 * Example:
 * findPlanets(listOf("Earth", "Mars", "Neptune"), listOf("Jupiter", "Pluto", "Mars")) // Output: ["Mars"]
 */
fun findPlanets(p1: List<String>, p2: List<String>): List<String> {

    // Retrieve the planets that are common to both lists using set intersection
    val commonPlanets = p1.intersect(p2)

    // Sort the resulting planets and return as a list
    return commonPlanets.sorted()
}