/**
 * Write a function that takes two arguments, 'a' and 'b', representing the real and imaginary parts of a complex number
 * respectively. The function should return a string representation of the complex number.
 *
 * For example:
 * complexToString(2, 3) -> "2 + 3j"
 * complexToString(-4, 5) -> "-4 + 5j"
 * complexToString(0, -2) -> "-2j"
 */
fun complexToString(a: Int, b: Int): String {

    return when {
        a == 0 && b == 0 -> "0"
        a == 0 -> if (b != -1) "$b j" else "-j"
        b == 0 -> a.toString()
        else -> {
            val sign = if (b > 0) "+" else "-"
            val bAbs = Math.abs(b)
            "$a $sign $bAbs j"
        }
    }
}
/**
 * Write a function that takes two arguments, 'a' and 'b', representing the real and imaginary parts of a complex number
 * respectively. The function should return a string representation of the complex number.
 *
 * For example:
 * complexToString(2, 3) -> "2 + 3j"
 * complexToString(-4, 5) -> "-4 + 5j"
 * complexToString(0, -2) -> "-2j"
 */
fun complexToString(a: Int, b: Int): String {
/**
 * Write a function that takes two arguments, 'a' and 'b', representing the real and imaginary parts of a complex number
 * respectively. The function should return a string representation of the complex number.
 *
 * For example:
 * complexToString(2, 3) -> "2 + 3j"
 * complexToString(-4, 5) -> "-4 + 5j"
 * complexToString(0, -2) -> "-2j"
 */
fun complexToString(a: Int, b: Int): String {

    return when {
        a == 0 && b == 0 -> "0"
        a == 0 -> if (b != -1) "$b j" else "-j"
        b == 0 -> a.toString()
        else -> {
            val sign = if (b > 0) "+" else "-"
            val bAbs = Math.abs(b)
            "$a $sign $bAbs j"
        }
    }
}