Skip to content

Commit

Permalink
Day 14
Browse files Browse the repository at this point in the history
  • Loading branch information
kohloderso committed Dec 26, 2023
1 parent 17f3d47 commit 85bc065
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/solutions23/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ inline fun<reified A> transpose(grid: Array<Array<A>>): Array<Array<A>> {
}
}

inline fun<reified A> rotateRight(grid: Array<Array<A>>): Array<Array<A>> {
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<reified A> cartesianProd(lists: List<List<A>>): List<List<A>> {
return lists.fold(listOf(listOf<A>())) { acc, list ->
Expand Down

0 comments on commit 85bc065

Please sign in to comment.