/**
 * Given a list of polygons and a list of points, 
 * append each point to the corresponding polygon in the polygonList
 * by using a continue statement to skip invalid points.
 *
 * @param polygonList A list of polygons represented as strings.
 * @param pointList A list of points represented as tuples.
 * @return The modified polygonList with points appended.
 */
fun appendElements(polygonList: MutableList<String>, pointList: List<Pair<Int, Int>>): MutableList<String> {

    // Iterate over each polygon
    for ((i, polygon) in polygonList.withIndex()) {
        // Check if the polygon is valid
        if (polygon !is String) {
            println("Invalid polygon at index $i. Skipping...")
            continue
        }

        // Iterate over each point
        for (point in pointList) {
            // Check if the point is valid
            if (point !is Pair<*, *>) {
                println("Invalid point at index ${pointList.indexOf(point)}. Skipping...")
                continue
            }

            // Append the point to the polygon
            polygonList[i] += point.toString()
        }
    }

    return polygonList
}
/**
 * Given a list of polygons and a list of points, 
 * append each point to the corresponding polygon in the polygonList
 * by using a continue statement to skip invalid points.
 *
 * @param polygonList A list of polygons represented as strings.
 * @param pointList A list of points represented as tuples.
 * @return The modified polygonList with points appended.
 */
fun appendElements(polygonList: MutableList<String>, pointList: List<Pair<Int, Int>>): MutableList<String> {
/**
 * Given a list of polygons and a list of points, 
 * append each point to the corresponding polygon in the polygonList
 * by using a continue statement to skip invalid points.
 *
 * @param polygonList A list of polygons represented as strings.
 * @param pointList A list of points represented as tuples.
 * @return The modified polygonList with points appended.
 */
fun appendElements(polygonList: MutableList<String>, pointList: List<Pair<Int, Int>>): MutableList<String> {

    // Iterate over each polygon
    for ((i, polygon) in polygonList.withIndex()) {
        // Check if the polygon is valid
        if (polygon !is String) {
            println("Invalid polygon at index $i. Skipping...")
            continue
        }

        // Iterate over each point
        for (point in pointList) {
            // Check if the point is valid
            if (point !is Pair<*, *>) {
                println("Invalid point at index ${pointList.indexOf(point)}. Skipping...")
                continue
            }

            // Append the point to the polygon
            polygonList[i] += point.toString()
        }
    }

    return polygonList
}