Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 81deba8

Browse files
1
1 parent 440bbf4 commit 81deba8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎src/main/kotlin/p35xx/Problem3516.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package p35xx
2+
3+
import util.expect
4+
import kotlin.math.absoluteValue
5+
import kotlin.math.sign
6+
7+
fun main() {
8+
class Solution {
9+
fun findClosest(x: Int, y: Int, z: Int): Int {
10+
return (x - z).absoluteValue.compareTo((y - z).absoluteValue).let {
11+
((it + 1) / 2 + 1) * it.sign.absoluteValue
12+
}
13+
}
14+
}
15+
16+
expect {
17+
Solution().findClosest(
18+
1, 2, 3
19+
)
20+
}
21+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /