AYA5D2EYQBZRYF5NI6H4WRLWIYLGWYV4BCU3LWLSJZSLZZMWUYDAC fun filter(lines: List<List<Int>>, fn: KFunction1<List<Int>, Int>): List<Int> {var index = 0var candidates = lineswhile (candidates.size > 1) {candidates = candidates.filter { line -> line[index] == fn(candidates.column(index)) }index++}return candidates.first()}
fun filter(lines: List<List<Int>>, fn: KFunction1<List<Int>, Int>): List<Int> =lines.indices.fold(lines) { candidates, index ->if (candidates.size == 1) candidateselse candidates.filter { line -> line[index] == fn(candidates.column(index)) } }.single()