You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
627 B
38 lines
627 B
package main
|
|
|
|
import (
|
|
adventoc2024 "adventoc/2024"
|
|
"bytes"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
type puzzle interface {
|
|
Part1(io.Reader) string
|
|
Part2(io.Reader) string
|
|
}
|
|
|
|
var puzzles = map[string]puzzle{
|
|
"1": adventoc2024.Day1{},
|
|
"2": adventoc2024.Day2{},
|
|
"3": adventoc2024.Day3{},
|
|
"4": adventoc2024.Day4{},
|
|
"5": adventoc2024.Day5{},
|
|
}
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
puzzle, ok := puzzles[flag.Arg(0)]
|
|
if !ok {
|
|
log.Fatalf("invalid puzzle day %s", flag.Arg(0))
|
|
}
|
|
|
|
buf := new(bytes.Buffer)
|
|
tee := io.TeeReader(os.Stdin, buf)
|
|
|
|
fmt.Println("Part 1:", puzzle.Part1(tee))
|
|
fmt.Println("Part 2:", puzzle.Part2(buf))
|
|
}
|
|
|