Compare commits

..

No commits in common. "c3fa7d0ff8cbcfea07f7b797f6ecb75064594f28" and "588561be7c05a63d6cecc9c561d91e60303f38c4" have entirely different histories.

10 changed files with 20 additions and 84 deletions

1
.gitignore vendored
View File

@ -7,7 +7,6 @@
*.dll *.dll
*.so *.so
*.dylib *.dylib
bin/
# Test binary, built with `go test -c` # Test binary, built with `go test -c`
*.test *.test

View File

@ -1,6 +0,0 @@
goos: linux
goarch: amd64
pkg: github.com/onyx-and-iris/aoc2024/day-01/internal/one
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
BenchmarkMain-12 1000000000 0.0006628 ns/op
ok github.com/onyx-and-iris/aoc2024/day-01/internal/one 0.009s

View File

@ -1,15 +0,0 @@
package one
import (
_ "embed"
"os"
"testing"
)
//go:embed testdata/input.txt
var data []byte
func BenchmarkMain(b *testing.B) {
os.Stdout, _ = os.Open(os.DevNull)
Solve(data)
}

View File

@ -1,6 +0,0 @@
goos: linux
goarch: amd64
pkg: github.com/onyx-and-iris/aoc2024/day-01/internal/two
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
BenchmarkMain-12 1000000000 0.001179 ns/op
ok github.com/onyx-and-iris/aoc2024/day-01/internal/two 0.011s

View File

@ -10,7 +10,8 @@ import (
"fmt" "fmt"
"log" "log"
problems "github.com/onyx-and-iris/aoc2024/day-01" "github.com/onyx-and-iris/aoc2024/day-01/internal/one"
"github.com/onyx-and-iris/aoc2024/day-01/internal/two"
) )
//go:embed testdata //go:embed testdata
@ -25,5 +26,15 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
problems.Solve(data) val, err := one.Solve(data)
if err != nil {
log.Fatal(err)
}
fmt.Printf("solution one: %d\n", val)
val, err = two.Solve(data)
if err != nil {
log.Fatal(err)
}
fmt.Printf("solution two: %d\n", val)
} }

View File

@ -1,15 +1,11 @@
package two package main
import ( import (
_ "embed"
"os" "os"
"testing" "testing"
) )
//go:embed testdata/input.txt
var data []byte
func BenchmarkMain(b *testing.B) { func BenchmarkMain(b *testing.B) {
os.Stdout, _ = os.Open(os.DevNull) os.Stdout, _ = os.Open(os.DevNull)
Solve(data) main()
} }

View File

@ -16,12 +16,10 @@ vet: fmt
$(GO) vet ./... $(GO) vet ./...
build: vet | $(BIN_DIR) build: vet | $(BIN_DIR)
$(GO) build -o $(EXE) ./cmd/cli/ $(GO) build -o $(EXE) .
bench: bench:
$(GO) test ./internal/one/ -bench=. > internal/one/benchmark $(GO) test . -test.count=10 -bench=. > benchmark
$(GO) test ./internal/two/ -bench=. > internal/two/benchmark
$(GO) test . -count=10 -bench=. > benchmark
$(BIN_DIR): $(BIN_DIR):
@mkdir -p $@ @mkdir -p $@

View File

@ -1,23 +0,0 @@
package day01
import (
"fmt"
"log"
"github.com/onyx-and-iris/aoc2024/day-01/internal/one"
"github.com/onyx-and-iris/aoc2024/day-01/internal/two"
)
func Solve(data []byte) {
val, err := one.Solve(data)
if err != nil {
log.Fatal(err)
}
fmt.Printf("solution one: %d\n", val)
val, err = two.Solve(data)
if err != nil {
log.Fatal(err)
}
fmt.Printf("solution two: %d\n", val)
}

View File

@ -1,15 +0,0 @@
package day01
import (
_ "embed"
"os"
"testing"
)
//go:embed testdata/input.txt
var data []byte
func BenchmarkMain(b *testing.B) {
os.Stdout, _ = os.Open(os.DevNull)
Solve(data)
}

View File

@ -7,8 +7,7 @@ if [ -d day-"$name" ]; then
exit 1 exit 1
fi fi
mkdir -p "$name"/cmd/cli/testdata \ mkdir -p "$name"/testdata
"$name"/testdata "$name"/internal/one/testdata "$name"/internal/two/testdata
touch "$name"/makefile touch "$name"/makefile
cat <<EOT >> "$name"/makefile cat <<EOT >> "$name"/makefile
@ -33,9 +32,7 @@ build: vet | \$(BIN_DIR)
\$(GO) build -o \$(EXE) ./\$(SRC_DIR) \$(GO) build -o \$(EXE) ./\$(SRC_DIR)
bench: bench:
\$(GO) test ./internal/one/ -bench=. > internal/one/benchmark \$(GO) test . -test.count=10 -bench=. > benchmark
\$(GO) test ./internal/two/ -bench=. > internal/two/benchmark
\$(GO) test . -count=10 -bench=. > benchmark
\$(BIN_DIR): \$(BIN_DIR):
@mkdir -p \$@ @mkdir -p \$@
@ -44,7 +41,7 @@ clean:
@rm -rv \$(BIN_DIR) @rm -rv \$(BIN_DIR)
EOT EOT
cat <<EOT >> "$name"/cmd/cli/main.go cat <<EOT >> "$name"/solution.go
/******************************************************************************** /********************************************************************************
Advent of Code 2024 - $name Advent of Code 2024 - $name
********************************************************************************/ ********************************************************************************/