/**
 * Given a list of colors and a color to match, this function returns the positions of all occurrences of the matching color.
 * If the color to match is null, it should treat it as a placeholder and return the positions of all null elements in the list.
 *
 * @param colors A list of colors.
 * @param colorToMatch The color to match or null.
 * @return A list containing the positions of matching color occurrences or null occurrences.
 */
fun findMatchingColorPositions(colors: List<String?>, colorToMatch: String?): List<Int> {

    val positions = mutableListOf<Int>()
    for ((index, color) in colors.withIndex()) {
        if (colorToMatch == null) {
            // Instruction: Using a for loop, append the index of all null occurrences to the positions list
            if (color == null) {
                positions.add(index)
            }
        } else {
            // Instruction: Using a for loop, append the index of all occurrences of the colorToMatch to the positions list
            if (color == colorToMatch) {
                positions.add(index)
            }
        }
    }
    return positions
}
/**
 * Given a list of colors and a color to match, this function returns the positions of all occurrences of the matching color.
 * If the color to match is null, it should treat it as a placeholder and return the positions of all null elements in the list.
 *
 * @param colors A list of colors.
 * @param colorToMatch The color to match or null.
 * @return A list containing the positions of matching color occurrences or null occurrences.
 */
fun findMatchingColorPositions(colors: List<String?>, colorToMatch: String?): List<Int> {
/**
 * Given a list of colors and a color to match, this function returns the positions of all occurrences of the matching color.
 * If the color to match is null, it should treat it as a placeholder and return the positions of all null elements in the list.
 *
 * @param colors A list of colors.
 * @param colorToMatch The color to match or null.
 * @return A list containing the positions of matching color occurrences or null occurrences.
 */
fun findMatchingColorPositions(colors: List<String?>, colorToMatch: String?): List<Int> {

    val positions = mutableListOf<Int>()
    for ((index, color) in colors.withIndex()) {
        if (colorToMatch == null) {
            // Instruction: Using a for loop, append the index of all null occurrences to the positions list
            if (color == null) {
                positions.add(index)
            }
        } else {
            // Instruction: Using a for loop, append the index of all occurrences of the colorToMatch to the positions list
            if (color == colorToMatch) {
                positions.add(index)
            }
        }
    }
    return positions
}