diff --git a/kt/rotating-the-box.kt b/kt/rotating-the-box.kt new file mode 100644 index 0000000..8d9c8df --- /dev/null +++ b/kt/rotating-the-box.kt @@ -0,0 +1,24 @@ +class Solution { + fun rotateTheBox(box: Array): Array { + val (rows, cols) = box.size to box[0].size + val rotated = Array(cols) { CharArray(rows) { '.' } } + + (0.. + (0.. + when (box[y][x]) { + '#' -> { + rotated[lowestEmpty][rows - y - 1] = '#' + lowestEmpty - 1 + } + '*' -> { + rotated[x][rows - y - 1] = '*' + x - 1 + } + else -> lowestEmpty + } + } + } + + return rotated + } +}