You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
670 B

package helper
import (
"io/ioutil"
"strconv"
"strings"
)
func GetInput(filename string) ([]string, error) {
content, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
lines := strings.Split(string(content), "\n")
return lines, err
}
func GetFile(filename string) (string, error) {
content, err := ioutil.ReadFile(filename)
if err != nil {
return "", err
}
return string(content), err
}
func MapToNumber(strings []string) ([]int, error) {
var numbers []int
for _, line := range strings {
number, err := strconv.Atoi(line)
if err != nil {
return numbers, err
}
numbers = append(numbers, number)
}
return numbers, nil
}