/** * I think this is the easiest problem. Straight forward O(n^2) problem. */ import kotlin.math.pow import kotlin.math.sqrt fun main() { val reader = System.`in`.bufferedReader() val n = reader.readLine().toInt() val input = reader.lineSequence().take(n).map { string -> string.split(" ", limit = 3) .map { it.toDouble() } .let { (x, y, z) -> Coordinate(x, y, z) } }.toList() println((0 until input.size - 2).minOf { index -> input[index].let { current -> input.drop(index + 1).minOf { current.distance(it) } } }) } typealias Coordinate = Triple inline fun Coordinate.distance(other: Coordinate) = sqrt((first - other.first).pow(2) + (second - other.second).pow(2) + (third - other.third).pow(2))