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
}
