Add day 2 solution.
This commit is contained in:
24
2018/internal/util/input.go
Normal file
24
2018/internal/util/input.go
Normal file
@ -0,0 +1,24 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
)
|
||||
|
||||
// ReadInput isn't here to make friends. It is highly specific to this domain.
|
||||
// It assumes the first argument on the command-line is a file with input. It
|
||||
// returns an array of strings containing the lines of that file.
|
||||
func ReadInput() []string {
|
||||
file, err := os.Open(os.Args[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
lines := []string{}
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
return lines
|
||||
}
|
Reference in New Issue
Block a user