/**
 * Converts polar representation of complex numbers to rectangular form.
 *
 * @param polar A tuple containing the angle in degrees and the magnitude of the complex number.
 * @return The rectangular form of the complex number.
 *
 * Example:
 * polarToComplex(Pair(45.0, 5.0)) // (3.5355339059327378+3.5355339059327373i)
 */
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin


fun polarToComplex(polar: Pair<Double, Double>): Complex {

    val angle = polar.first
    val magnitude = polar.second

    val radians = angle * PI / 180

    val x = magnitude * cos(radians)
    val y = magnitude * sin(radians)

    return Complex(x, y)
}

data class Complex(val real: Double, val imaginary: Double) {
    override fun toString(): String {
        return "($real+${imaginary}i)"
    }
}
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin

/**
 * Converts polar representation of complex numbers to rectangular form.
 *
 * @param polar A tuple containing the angle in degrees and the magnitude of the complex number.
 * @return The rectangular form of the complex number.
 *
 * Example:
 * polarToComplex(Pair(45.0, 5.0)) // (3.5355339059327378+3.5355339059327373i)
 */
fun polarToComplex(polar: Pair<Double, Double>): Complex {
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin

/**
 * Converts polar representation of complex numbers to rectangular form.
 *
 * @param polar A tuple containing the angle in degrees and the magnitude of the complex number.
 * @return The rectangular form of the complex number.
 *
 * Example:
 * polarToComplex(Pair(45.0, 5.0)) // (3.5355339059327378+3.5355339059327373i)
 */
fun polarToComplex(polar: Pair<Double, Double>): Complex {

    val angle = polar.first
    val magnitude = polar.second

    val radians = angle * PI / 180

    val x = magnitude * cos(radians)
    val y = magnitude * sin(radians)

    return Complex(x, y)
}

data class Complex(val real: Double, val imaginary: Double) {
    override fun toString(): String {
        return "($real+${imaginary}i)"
    }
}