Day 9 solution.
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user