/**
 * Given a list of gene names and their corresponding expression values,
 * this function calculates the log2 fold change for each gene and returns a map
 * with the gene name as the key and the fold change as the value.
 *
 * @param geneNames A list of gene names.
 * @param expressionValues A list of expression values for each gene.
 * @return A map containing the gene name as the key and the log2 fold change as the value.
 */
fun geneExpressionAnalysis(geneNames: List<String>, expressionValues: List<Int>): Map<String, Int> {

    val foldChange = mutableMapOf<String, Int>()

    for (i in geneNames.indices) {
        foldChange[geneNames[i]] = if (i < expressionValues.size - 1) {
            expressionValues[i] shl expressionValues[i + 1]
        } else {
            expressionValues[i] shr expressionValues[i - 1]
        }
    }

    return foldChange
}

// Exercise usage example
/**
 * Given a list of gene names and their corresponding expression values,
 * this function calculates the log2 fold change for each gene and returns a map
 * with the gene name as the key and the fold change as the value.
 *
 * @param geneNames A list of gene names.
 * @param expressionValues A list of expression values for each gene.
 * @return A map containing the gene name as the key and the log2 fold change as the value.
 */
fun geneExpressionAnalysis(geneNames: List<String>, expressionValues: List<Int>): Map<String, Int> {
/**
 * Given a list of gene names and their corresponding expression values,
 * this function calculates the log2 fold change for each gene and returns a map
 * with the gene name as the key and the fold change as the value.
 *
 * @param geneNames A list of gene names.
 * @param expressionValues A list of expression values for each gene.
 * @return A map containing the gene name as the key and the log2 fold change as the value.
 */
fun geneExpressionAnalysis(geneNames: List<String>, expressionValues: List<Int>): Map<String, Int> {

    val foldChange = mutableMapOf<String, Int>()

    for (i in geneNames.indices) {
        foldChange[geneNames[i]] = if (i < expressionValues.size - 1) {
            expressionValues[i] shl expressionValues[i + 1]
        } else {
            expressionValues[i] shr expressionValues[i - 1]
        }
    }

    return foldChange
}

// Exercise usage example