day 04
This commit is contained in:
32
pkg/aoc/readFile.go
Normal file
32
pkg/aoc/readFile.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user