|
@ -2,9 +2,9 @@ package main |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"bufio" |
|
|
"bufio" |
|
|
|
|
|
"bytes" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"io" |
|
|
"io" |
|
|
"log" |
|
|
|
|
|
"os" |
|
|
"os" |
|
|
"sort" |
|
|
"sort" |
|
|
) |
|
|
) |
|
@ -53,13 +53,9 @@ func part2(r io.Reader) string { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|
f, err := os.Open("day01.txt") |
|
|
buf := new(bytes.Buffer) |
|
|
if err != nil { |
|
|
tee := io.TeeReader(os.Stdin, buf) |
|
|
log.Fatal(err) |
|
|
|
|
|
} |
|
|
|
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
|
|
|
fmt.Println(part1(f)) |
|
|
fmt.Println(part1(tee)) |
|
|
f.Seek(0, 0) |
|
|
fmt.Println(part2(buf)) |
|
|
fmt.Println(part2(f)) |
|
|
|
|
|
} |
|
|
} |
|
|