mirror of
https://github.com/RussellChamp/advent-of-code-2021.git
synced 2026-10-27 21:52:32 +00:00
day 1
This commit is contained in:
1 parent
1208efd0af
commit
f6f6a849ec
4 files changed
+155
-3
No files matched your search
@@ -0,0 +1,37 @@
|
||||
/* 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()
|
||||
}
|
||||
Reference in new issue
Block a user