diff --git a/src/solutions23/Utils.kt b/src/solutions23/Utils.kt index 60cc308..979f2a9 100644 --- a/src/solutions23/Utils.kt +++ b/src/solutions23/Utils.kt @@ -72,6 +72,16 @@ inline fun transpose(grid: Array>): Array> { } } +inline fun rotateRight(grid: Array>): Array> { + val cols = grid[0].size + val rows = grid.size + return Array(cols) { j -> + Array(rows) { i -> + grid[rows-i-1][j] + } + } +} + //compute cartesian product of a list of lists inline fun cartesianProd(lists: List>): List> { return lists.fold(listOf(listOf())) { acc, list ->