[백준] Equality (13985)(kotlin)

원본 문제

문제 설명

You are grading an arithmetic quiz. The quiz asks a student for the sum of the numbers. Determine if the student taking the quiz got the question correct.

입력

The first and the only line of input contains a string of the form:

a + b = c

It is guaranteed that a, b, and c are single-digit positive integers. The input line will have exactly 9 characters, formatted exactly as shown, with a single space separating each number and arithmetic operator.

출력

Print, on a single line, YES if the sum is correct; otherwise, print NO.

테스트 케이스

입력 출력
1 + 2 = 3 YES
2 + 2 = 5 NO

문제 풀이1

fun main(args: Array<String>) = println(
    readLine()!!
        .replace(" ", "")
        .split("+", "=")
        .map { it.toInt() }
        .let {
            if (it[0] + it[1] == it[2]) "YES"
            else "NO"
        }
)