Day 9 solution.

This commit is contained in:
2020-12-11 10:00:29 +00:00
parent b0147157f1
commit 4e10039bfb
2 changed files with 142 additions and 0 deletions

View File

@ -9,6 +9,27 @@ import (
"strings"
)
func InputParserInts(filename string) []int {
file, err := os.Open(filename)
defer file.Close()
if err != nil {
log.Panicf(err.Error())
}
values := make([]int, 0)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
x, err := strconv.Atoi(scanner.Text())
if err != nil {
log.Panicf(err.Error())
}
values = append(values, x)
}
return values
}
func InputParserIntMap(filename string) map[int]bool {
file, err := os.Open(filename)
defer file.Close()