This commit is contained in:
Simon Ziegler
2025-12-04 15:13:42 +01:00
parent e34c4084c6
commit 642045825f
9 changed files with 259 additions and 9 deletions

32
pkg/aoc/readFile.go Normal file
View File

@@ -0,0 +1,32 @@
package aoc
import (
"os"
"strings"
)
func ReadFile(test bool) string {
fileName := "input"
if test {
fileName = "test"
}
if cont, err := os.ReadFile(fileName); err != nil {
panic(err)
} else {
return strings.TrimSpace(string(cont))
}
}
func ReadFileRows(test bool) []string {
cont := ReadFile(test)
rows := strings.Split(cont, "\n")
for ii, rr := range rows {
rows[ii] = strings.TrimSpace(rr)
}
return rows
}

13
pkg/aoc/stringToGrid.go Normal file
View File

@@ -0,0 +1,13 @@
package aoc
import "strings"
func RowsToGrid(r []string) [][]string {
grid := make([][]string, len(r))
for ii, rr := range r {
grid[ii] = strings.Split(rr, "")
}
return grid
}