// SS import StdDraw.* fun vsplit(n: Int, width: Double, height: Double, x: Double, y: Double) { if (n < 1) return val x0 = x - width/4.0 val x1 = x + width/4.0 line(x0, y, x1, y) hsplit(n-1, width/2.0, height, x0, y) hsplit(n-1, width/2.0, height, x1, y) } fun hsplit(n: Int, width: Double, height: Double, x: Double, y: Double) { if (n < 1) return val y0 = y - height/4.0 val y1 = y + height/4.0 line(x, y0, x, y1) vsplit(n-1, width, height/2.0, x, y0) vsplit(n-1, width, height/2.0, x, y1) } fun main(args: Array) = vsplit(args[0].toInt(), 1.0, 1.0, 0.5, 0.5)