Day 9 solution.
This commit is contained in:
parent
b0147157f1
commit
4e10039bfb
2 changed files with 142 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue