[백준] Judging Moose (15025)(kotlin)

원본 문제

문제 설명

When determining the age of a bull moose, the number of tines (sharp points), extending from the main antlers, can be used. An older bull moose tends to have more tines than a younger moose. However, just counting the number of tines can be misleading, as a moose can break off the tines, for example when fighting with other moose. Therefore, a point system is used when describing the antlers of a bull moose.

The point system works like this: If the number of tines on the left side and the right side match, the moose is said to have the even sum of the number of points. So, “an even 6-point moose”, would have three tines on each side. If the moose has a different number of tines on the left and right side, the moose is said to have twice the highest number of tines, but it is odd. So “an odd 10-point moose” would have 5 tines on one side, and 4 or less tines on the other side.

Can you figure out how many points a moose has, given the number of tines on the left and right side?

입력

The input contains a single line with two integers ℓ and r, where 0 ≤ ℓ ≤ 20 is the number of tines on the left, and 0 ≤ r ≤ 20 is the number of tines on the right.

출력

Output a single line describing the moose. For even pointed moose, output “Even x” where x is the points of the moose. For odd pointed moose, output “Odd x” where x is the points of the moose. If the moose has no tines, output “Not a moose”

테스트 케이스

입력 출력
2 3 Odd 6
3 3 Even 6
0 0 Not a moose

문제 풀이1

import kotlin.math.max

fun main(args: Array<String>) = println(
    readLine()!!
        .split(" ")
        .let {
            val left = it[0].toInt()
            val right = it[1].toInt()

            if (left == right) {
                if (left == 0) "Not a moose"
                else "Even ${right shl 1}"
            } else {
                "Odd ${max(left, right) shl 1}"
            }
        }
)