mirror of
https://github.com/RussellChamp/advent-of-code-2021.git
synced 2026-10-27 21:52:32 +00:00
37 lines
515 B
Plaintext
37 lines
515 B
Plaintext
/* Day #: */
|
|||
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bufio"
|
||
|
|
"fmt"
|
||
|
|
"os"
|
||
|
|
)
|
||
|
|
|
||
|
|
func check(e error) {
|
||
|
|
if e != nil {
|
||
|
|
fmt.Println("Oh snap!")
|
||
|
|
panic(e)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ReadAllLines(input *os.File) []string {
|
||
|
|
scanner := bufio.NewScanner(input)
|
||
|
|
var text []string
|
||
|
|
for scanner.Scan() {
|
||
|
|
text = append(text, scanner.Text())
|
||
|
|
}
|
||
|
|
return text
|
||
|
|
}
|
||
|
|
|
||
|
|
func main() {
|
||
|
|
|
||
|
|
input1, err := os.Open("./input.txt")
|
||
|
|
check(err)
|
||
|
|
|
||
|
|
text := ReadAllLines(input1)
|
||
|
|
input1.Close()
|
||
|
|
|
||
|
|
fmt.Printf("Read %d lines from %s\n", len(text), "input.txt")
|
||
|
|
|
||
|
|
fmt.Println()
|
||
|
|
}
|