aoc/internal/input/input.go

31 lines
481 B
Go

package input
import (
"aoc/internal/global"
"os"
"strconv"
"strings"
)
func GetInput(path string) string {
data, err := os.ReadFile(path)
global.E(err)
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)
global.E(err)
r = append(r, t)
}
return r
}