/**
 * This function checks for collisions between players and obstacles in a game.
 *
 * @param players A set of player coordinates in the format (x, y).
 * @param obstacles A set of obstacle coordinates in the format (x, y).
 * @return A list of collided players with obstacles.
 *
 * Example:
 * checkCollision(setOf(Pair(0, 0), Pair(1, 1), Pair(2, 2)), setOf(Pair(1, 1), Pair(3, 3), Pair(4, 4)))
 * // Returns [(1, 1)]
 */
fun checkCollision(players: Set<Pair<Int, Int>>, obstacles: Set<Pair<Int, Int>>): List<Pair<Int, Int>> {

    val collidedPlayers = mutableListOf<Pair<Int, Int>>()

    for (player in players) {
        val (x, y) = player
        var collisionDetected = false

        for (obstacle in obstacles) {
            val (ox, oy) = obstacle

            if (x == ox && y == oy) {
                collisionDetected = true
                break
            }
        }

        if (collisionDetected) {
            collidedPlayers.add(player)
        }
    }

    return collidedPlayers
}
/**
 * This function checks for collisions between players and obstacles in a game.
 *
 * @param players A set of player coordinates in the format (x, y).
 * @param obstacles A set of obstacle coordinates in the format (x, y).
 * @return A list of collided players with obstacles.
 *
 * Example:
 * checkCollision(setOf(Pair(0, 0), Pair(1, 1), Pair(2, 2)), setOf(Pair(1, 1), Pair(3, 3), Pair(4, 4)))
 * // Returns [(1, 1)]
 */
fun checkCollision(players: Set<Pair<Int, Int>>, obstacles: Set<Pair<Int, Int>>): List<Pair<Int, Int>> {
/**
 * This function checks for collisions between players and obstacles in a game.
 *
 * @param players A set of player coordinates in the format (x, y).
 * @param obstacles A set of obstacle coordinates in the format (x, y).
 * @return A list of collided players with obstacles.
 *
 * Example:
 * checkCollision(setOf(Pair(0, 0), Pair(1, 1), Pair(2, 2)), setOf(Pair(1, 1), Pair(3, 3), Pair(4, 4)))
 * // Returns [(1, 1)]
 */
fun checkCollision(players: Set<Pair<Int, Int>>, obstacles: Set<Pair<Int, Int>>): List<Pair<Int, Int>> {

    val collidedPlayers = mutableListOf<Pair<Int, Int>>()

    for (player in players) {
        val (x, y) = player
        var collisionDetected = false

        for (obstacle in obstacles) {
            val (ox, oy) = obstacle

            if (x == ox && y == oy) {
                collisionDetected = true
                break
            }
        }

        if (collisionDetected) {
            collidedPlayers.add(player)
        }
    }

    return collidedPlayers
}