Browse Source

using tee reader instead of seeking; use stdin for input

master
Alexander Avery 3 weeks ago
parent
commit
addd7ac71d
  1. 14
      2024/day01.go

14
2024/day01.go

@ -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))
}

Loading…
Cancel
Save