aoc/internal/utility/input.go

30 lines
446 B
Go
Raw Permalink Normal View History

2024-07-24 18:03:39 +00:00
package utility
2024-07-24 14:29:59 +00:00
import (
"os"
"strconv"
"strings"
)
func GetInput(path string) string {
data, err := os.ReadFile(path)
2024-07-24 18:03:39 +00:00
E(err)
2024-07-24 14:29:59 +00:00
return string(data)
}
func GetLines(path string) []string {
data := GetInput(path)
return strings.Split(data, "\n")
}
func GetInts(path string) []int {
data := GetLines(path)
r := make([]int, len(data))
for _, line := range data {
t, err := strconv.Atoi(line)
2024-07-24 18:03:39 +00:00
E(err)
2024-07-24 14:29:59 +00:00
r = append(r, t)
}
return r
}