/**
 * As a lawyer, you are often presented with a large number of documents related to a case.
 * You need to find the specific documents that are related to a given case number.
 *
 * @param caseNumber The case number for which the related documents need to be found.
 * @param documents A list of document numbers related to various cases.
 * @return A list of document numbers that are related to the given case number.
 */
fun findCaseRelatedDocuments(caseNumber: Int, documents: List<Int>): List<Int> {

    val caseDocuments = mutableListOf<Int>()

    // Loop through each document number in the list
    for (document in documents) {
        // Extract the case number from the document number
        val extractedCaseNumber = document.toString().substring(0, 4).toInt()

        // Check if the extracted case number matches the given case number
        if (extractedCaseNumber == caseNumber) {
            // Add the document number to the caseDocuments list
            caseDocuments.add(document)
        }
    }

    return caseDocuments
}

// Given case number and document list
val caseNumber = 1234
val documentList = listOf(1234001, 1234002, 2345001, 2345002, 3456001, 3456002, 4567001)
/**
 * As a lawyer, you are often presented with a large number of documents related to a case.
 * You need to find the specific documents that are related to a given case number.
 *
 * @param caseNumber The case number for which the related documents need to be found.
 * @param documents A list of document numbers related to various cases.
 * @return A list of document numbers that are related to the given case number.
 */
fun findCaseRelatedDocuments(caseNumber: Int, documents: List<Int>): List<Int> {
/**
 * As a lawyer, you are often presented with a large number of documents related to a case.
 * You need to find the specific documents that are related to a given case number.
 *
 * @param caseNumber The case number for which the related documents need to be found.
 * @param documents A list of document numbers related to various cases.
 * @return A list of document numbers that are related to the given case number.
 */
fun findCaseRelatedDocuments(caseNumber: Int, documents: List<Int>): List<Int> {

    val caseDocuments = mutableListOf<Int>()

    // Loop through each document number in the list
    for (document in documents) {
        // Extract the case number from the document number
        val extractedCaseNumber = document.toString().substring(0, 4).toInt()

        // Check if the extracted case number matches the given case number
        if (extractedCaseNumber == caseNumber) {
            // Add the document number to the caseDocuments list
            caseDocuments.add(document)
        }
    }

    return caseDocuments
}

// Given case number and document list
val caseNumber = 1234
val documentList = listOf(1234001, 1234002, 2345001, 2345002, 3456001, 3456002, 4567001)