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