/**
 * Given a list of complex number coordinates in the form of (x, y), convert each coordinate to its polar representation,
 * which consists of the distance from the origin (r) and the angle (theta) in radians.
 *
 * Example: polarRepresentation(listOf(Pair(3, 4), Pair(-2, 5))) should return listOf(Pair(5.0, 0.927), Pair(5.385, 2.819))
 *
 * The formula to calculate polar coordinates is: r = sqrt(x^2 + y^2) and theta = atan2(y, x)
 */
import kotlin.math.atan2
import kotlin.math.sqrt


fun polarRepresentation(coordinates: List<Pair<Int, Int>>): List<Pair<Double, Double>> {

    val polarCoordinates = mutableListOf<Pair<Double, Double>>()

    for (coordinate in coordinates) {
        val (x, y) = coordinate
        val r = sqrt((x * x + y * y).toDouble())
        val theta = atan2(y.toDouble(), x.toDouble())

        polarCoordinates.add(Pair(r, theta))
    }

    return polarCoordinates.map { Pair(it.first, it.second) }
}
import kotlin.math.atan2
import kotlin.math.sqrt

/**
 * Given a list of complex number coordinates in the form of (x, y), convert each coordinate to its polar representation,
 * which consists of the distance from the origin (r) and the angle (theta) in radians.
 *
 * Example: polarRepresentation(listOf(Pair(3, 4), Pair(-2, 5))) should return listOf(Pair(5.0, 0.927), Pair(5.385, 2.819))
 *
 * The formula to calculate polar coordinates is: r = sqrt(x^2 + y^2) and theta = atan2(y, x)
 */
fun polarRepresentation(coordinates: List<Pair<Int, Int>>): List<Pair<Double, Double>> {
import kotlin.math.atan2
import kotlin.math.sqrt

/**
 * Given a list of complex number coordinates in the form of (x, y), convert each coordinate to its polar representation,
 * which consists of the distance from the origin (r) and the angle (theta) in radians.
 *
 * Example: polarRepresentation(listOf(Pair(3, 4), Pair(-2, 5))) should return listOf(Pair(5.0, 0.927), Pair(5.385, 2.819))
 *
 * The formula to calculate polar coordinates is: r = sqrt(x^2 + y^2) and theta = atan2(y, x)
 */
fun polarRepresentation(coordinates: List<Pair<Int, Int>>): List<Pair<Double, Double>> {

    val polarCoordinates = mutableListOf<Pair<Double, Double>>()

    for (coordinate in coordinates) {
        val (x, y) = coordinate
        val r = sqrt((x * x + y * y).toDouble())
        val theta = atan2(y.toDouble(), x.toDouble())

        polarCoordinates.add(Pair(r, theta))
    }

    return polarCoordinates.map { Pair(it.first, it.second) }
}