From aeb0b8752a8ac459e24cd6cb65b9d75c733f9c63 Mon Sep 17 00:00:00 2001 From: xuu Date: Wed, 13 Dec 2023 17:02:16 -0700 Subject: [PATCH] chore: add day13 --- template/example.txt | 6 ------ tools.go | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/template/example.txt b/template/example.txt index c5bec3a..e69de29 100644 --- a/template/example.txt +++ b/template/example.txt @@ -1,6 +0,0 @@ -???.### 1,1,3 -.??..??...?##. 1,1,3 -?#?#?#?#?#?#?#? 1,3,1,6 -????.#...#... 4,1,1 -????.######..#####. 1,6,5 -?###???????? 3,2,1 \ No newline at end of file diff --git a/tools.go b/tools.go index 6c41c04..f3e239d 100644 --- a/tools.go +++ b/tools.go @@ -250,3 +250,19 @@ func ABS(i int) int { } return i } + +func Transpose[T any](matrix [][]T) [][]T { + rows, cols := len(matrix), len(matrix[0]) + + m := make([][]T, cols) + for i := range m { + m[i] = make([]T, rows) + } + + for i := 0; i < cols; i++ { + for j := 0; j < rows; j++ { + m[i][j] = matrix[j][i] + } + } + return m +} \ No newline at end of file