/**
 * This exercise focuses on infinite loops and the concept of null in Kotlin.
 * Your task is to write a function that takes a list of marketing data and checks if any player has an infinite loop.
 * The function should return the player's name if an infinite loop is found, and null if not.
 *
 * @param marketingData A list of maps containing marketing data for each player.
 * @return The name of the player if an infinite loop is found, otherwise null.
 */
fun intersectionOfLoopsAndNone(marketingData: List<Map<String, Any>>): String? {

    for (playerData in marketingData) {
        // Check if player's name is missing
        if (playerData["name"] == null) {
            return null
        }

        val playerName = playerData["name"] as String

        // Check if player's marketing points are missing
        if (playerData["marketing_points"] == null) {
            return null
        }

        val marketingPoints = playerData["marketing_points"] as Int

        // Check if player's marketing points are negative
        if (marketingPoints < 0) {
            return null
        }

        // Check if player's marketing points can lead to an infinite loop
        var points = marketingPoints
        while (points > 0) {
            points--
        }
    }
    return null
}
/**
 * This exercise focuses on infinite loops and the concept of null in Kotlin.
 * Your task is to write a function that takes a list of marketing data and checks if any player has an infinite loop.
 * The function should return the player's name if an infinite loop is found, and null if not.
 *
 * @param marketingData A list of maps containing marketing data for each player.
 * @return The name of the player if an infinite loop is found, otherwise null.
 */
fun intersectionOfLoopsAndNone(marketingData: List<Map<String, Any>>): String? {
/**
 * This exercise focuses on infinite loops and the concept of null in Kotlin.
 * Your task is to write a function that takes a list of marketing data and checks if any player has an infinite loop.
 * The function should return the player's name if an infinite loop is found, and null if not.
 *
 * @param marketingData A list of maps containing marketing data for each player.
 * @return The name of the player if an infinite loop is found, otherwise null.
 */
fun intersectionOfLoopsAndNone(marketingData: List<Map<String, Any>>): String? {

    for (playerData in marketingData) {
        // Check if player's name is missing
        if (playerData["name"] == null) {
            return null
        }

        val playerName = playerData["name"] as String

        // Check if player's marketing points are missing
        if (playerData["marketing_points"] == null) {
            return null
        }

        val marketingPoints = playerData["marketing_points"] as Int

        // Check if player's marketing points are negative
        if (marketingPoints < 0) {
            return null
        }

        // Check if player's marketing points can lead to an infinite loop
        var points = marketingPoints
        while (points > 0) {
            points--
        }
    }
    return null
}