This commit is contained in:
2025-01-13 18:44:06 +00:00
parent 4619bc7775
commit 29387606b0
36 changed files with 15386 additions and 12 deletions

View File

@@ -2,23 +2,39 @@ package main
import (
"fmt"
// "math/rand"
"time"
// "math/rand"
"os"
// "strings"
// "time"
"adventofcode2024/utils"
// "strings"
// "time"
"adventofcode2024/day01"
"adventofcode2024/day02"
"adventofcode2024/day03"
"adventofcode2024/day04"
"adventofcode2024/day06"
"adventofcode2024/day07"
"adventofcode2024/day08"
"adventofcode2024/day09"
"adventofcode2024/day10"
"adventofcode2024/day11"
"adventofcode2024/day12"
"adventofcode2024/day13"
"adventofcode2024/day14"
"adventofcode2024/day15"
"adventofcode2024/day16"
"adventofcode2024/day17"
"adventofcode2024/day18"
"adventofcode2024/day19"
"adventofcode2024/utils"
)
// Usage: go run main.go <NN>
// assumes input is in day<NN>/input.txt
func main() {
d := day()
fmt.Printf("Running day %02d\n", d)
start := time.Now()
switch d {
case 1:
fmt.Printf("part 1: %d\n", day01.Part1(utils.Readfile(d)))
@@ -32,14 +48,58 @@ func main() {
case 4:
fmt.Printf("part 1: %d\n", day04.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day04.Part2(utils.Readfile(d)))
case 6:
fmt.Printf("part 1: %d\n", day06.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day06.Part2(utils.Readfile(d)))
case 7:
fmt.Printf("part 1: %d\n", day07.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day07.Part2(utils.Readfile(d)))
case 8:
fmt.Printf("part 1: %d\n", day08.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day08.Part2(utils.Readfile(d)))
case 9:
fmt.Printf("part 1: %d\n", day09.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day09.Part2(utils.Readfile(d)))
case 10:
fmt.Printf("part 1: %d\n", day10.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day10.Part2(utils.Readfile(d)))
case 11:
fmt.Printf("part 1: %d\n", day11.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day11.Part2(utils.Readfile(d)))
case 12:
fmt.Printf("part 1: %d\n", day12.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day12.Part2(utils.Readfile(d)))
case 13:
fmt.Printf("part 1: %d\n", day13.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day13.Part2(utils.Readfile(d)))
case 14:
fmt.Printf("part 1: %d\n", day14.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day14.Part2(utils.Readfile(d)))
case 15:
fmt.Printf("part 1: %d\n", day15.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day15.Part2(utils.Readfile(d)))
case 16:
fmt.Printf("part 1: %d\n", day16.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day16.Part2(utils.Readfile(d)))
case 17:
fmt.Printf("part 1: %s\n", day17.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day17.Part2(utils.Readfile(d)))
case 18:
fmt.Printf("part 1: %d\n", day18.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day18.Part2(utils.Readfile(d)))
case 19:
fmt.Printf("part 1: %d\n", day19.Part1(utils.Readfile(d)))
fmt.Printf("part 2: %d\n", day19.Part2(utils.Readfile(d)))
default:
panic(fmt.Errorf("no such day: %d", d))
}
elapsed := time.Since(start)
fmt.Printf("Execution time: %s\n", elapsed)
}
// Reads day from os.Args.
func day() int {
latest := 3
latest := 18
if len(os.Args) == 1 {
return latest
}
@@ -52,7 +112,6 @@ func day() int {
return day
}
func genNext(n int) {
os.Mkdir(fmt.Sprintf("day%02d", n), 0755)
f, err := os.Create(fmt.Sprintf("day%02d/day%02d.go", n, n))
@@ -94,4 +153,4 @@ func TestPart2(t *testing.T) {
fmt.Printf("wrote day%02d/day%02d_test.go\n", n, n)
utils.GenInputFile(n)
}
}