fun main(args:Array) { val (r, k) = readLine()!!.split(" ").map(String::toInt) val (h, w) = readLine()!!.split(" ").map(String::toInt) val orig = (1..h).map { readLine()!!.toList() } // make base when(r) { 0 -> (1..h).map { (1..w).map { null }.toMutableList() } 90 -> (1..w).map { (1..h).map { null }.toMutableList() } 180 -> (1..h).map { (1..w).map { null }.toMutableList() } else -> (1..w).map { (1..h).map { null }.toMutableList() } }.let { base -> // 90 val lambdasy = mapOfInt>( 0 to { y -> y }, 90 to { y -> y }, 180 to { y -> w - 1 - y}, 270 to { y -> w - 1 - y } ) val lambdasx = mapOfInt>( 0 to { x -> x }, 90 to { x -> h - 1 - x }, 180 to { x -> h - 1 - x}, 270 to { x -> x } ) (0..w-1).map { y -> (0..h-1).map { x -> val transy = lambdasy[r]!!(y) val transx = lambdasx[r]!!(x) //h -1 - x base[transy][transx] = orig[x][y] } } base.map { xs -> (1..k).map { xs.map { x -> (1..k).map { print(x.toString()) } } println("") } } } }