mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2026-04-07 17:43:37 +00:00
Compare commits
100 Commits
e7aa98d637
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 68aaa634c9 | |||
| a93e6a7a05 | |||
| 5d6d8fdf79 | |||
| 75d10fffd0 | |||
| 7354aef102 | |||
| ae590042b5 | |||
| 21e942c56d | |||
| c125230c9b | |||
| 84c1013f2c | |||
| 2b675af081 | |||
| fd057f88ed | |||
| 064232967b | |||
| c70d4a74cf | |||
| feb0ae4617 | |||
| a6295375aa | |||
| aeb57b5cca | |||
| 0f48ed35ea | |||
| 156c1c13e0 | |||
| d689cd0a9a | |||
| 88f082080d | |||
| 51fed356af | |||
| a282338f29 | |||
| 4013cd6c7f | |||
| 83399a45c2 | |||
| dda597a577 | |||
| 942d2a8456 | |||
| 169fa86a69 | |||
| f430d4ed7b | |||
| 24bb0d40c9 | |||
| 4aaf594e23 | |||
| d244a9cc35 | |||
| 5a6947af2c | |||
| 33ee076cf1 | |||
| cdca21b3f3 | |||
| e97f05ea48 | |||
| 13a92834a1 | |||
| 1f033ea3a0 | |||
| ef120d05d4 | |||
| b2e0108fb0 | |||
| 31effc9d8e | |||
| 4bed4a8563 | |||
| 287a168293 | |||
| 5cc9a43723 | |||
| 3ccdd9fdf6 | |||
| 72d329ae57 | |||
| 03ef97051e | |||
| 22b442171b | |||
| 62665d4d10 | |||
| abf7abf3ea | |||
| 52541e7ca7 | |||
| a4e8e83844 | |||
| f6eeece8d7 | |||
| 1b0f02b430 | |||
| c3fa65e4a8 | |||
| f1cac7da7b | |||
| 17f2bc8223 | |||
| 9d7a9d5791 | |||
| 6cb3fd1654 | |||
| a0a25639cc | |||
| 1429ece4f4 | |||
| 090530ce72 | |||
| 415a41788b | |||
| e1322465af | |||
| d441f6a555 | |||
| 7b17f8edc1 | |||
| dcf3479d88 | |||
| 401bd4201b | |||
| 054d372470 | |||
| f7534c78d1 | |||
| fde954f97c | |||
| 540339b42d | |||
| 1f349178ed | |||
| 2dc1d494af | |||
| cf22aff066 | |||
| aafe39aa85 | |||
| 1e2188db1a | |||
| c12cc2c38e | |||
| 2c3e68d884 | |||
| c89f5611ed | |||
| fa02cb3bc7 | |||
| 503082d822 | |||
| 0236679639 | |||
| 6b7f79b6f0 | |||
| 965e704d39 | |||
| 5ed54e672b | |||
| c1b8cb3f18 | |||
| 9bfd45aee4 | |||
| d42df0cd84 | |||
| 1c60c034e3 | |||
| 3ce4a4112e | |||
| 02443ef244 | |||
| 08706ecc11 | |||
| 8bf3f603d5 | |||
| df605fba15 | |||
| 567ca72402 | |||
| d1308ffdfe | |||
| e67369041e | |||
| 886679a095 | |||
| b981b962a2 | |||
| 1ef43151b8 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -26,7 +26,7 @@ go.work.sum
|
||||
.env
|
||||
|
||||
# input files
|
||||
**/testdata/*.txt
|
||||
**/testdata/*
|
||||
|
||||
# scaffold
|
||||
mkfiles.sh
|
||||
17
.scaffold/aoc/hooks/post_scaffold.sh
Normal file
17
.scaffold/aoc/hooks/post_scaffold.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "{{ .Project }}" || exit 1
|
||||
|
||||
go mod init github.com/onyx-and-iris/aoc{{ .Scaffold.year }}/"{{ .Project }}"
|
||||
go mod tidy
|
||||
|
||||
# shellcheck disable=SC2001
|
||||
day=$(echo "{{ .Project }}" | sed 's/^day-0*//')
|
||||
|
||||
mkdir -p testdata
|
||||
curl "https://adventofcode.com/{{ .Scaffold.year }}/day/$day/input" -H "Cookie: session=$AOC_SESSION" > testdata/input.txt
|
||||
|
||||
|
||||
mkdir -p cmd/cli/testdata && ln testdata/input.txt cmd/cli/testdata/input.txt
|
||||
mkdir -p internal/one/testdata && ln testdata/input.txt internal/one/testdata/input.txt
|
||||
mkdir -p internal/two/testdata && ln testdata/input.txt internal/two/testdata/input.txt
|
||||
16
.scaffold/aoc/scaffold.yml
Normal file
16
.scaffold/aoc/scaffold.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
messages:
|
||||
pre: |
|
||||
Use this scaffold to generate a new AOC project.
|
||||
post: |
|
||||
# You've generated a new AOC project!
|
||||
|
||||
You can now run the following commands:
|
||||
|
||||
- `go run ./cmd/cli/` - Runs the main application and supports passing CLI args
|
||||
|
||||
questions:
|
||||
- name: year
|
||||
prompt:
|
||||
message: "What year is this project for?"
|
||||
default: "2024"
|
||||
type: "input"
|
||||
41
.scaffold/aoc/{{ .Project }}/cmd/cli/main.go
Normal file
41
.scaffold/aoc/{{ .Project }}/cmd/cli/main.go
Normal file
@@ -0,0 +1,41 @@
|
||||
/********************************************************************************
|
||||
Advent of Code {{ .Scaffold.year }} - {{ .Project }}
|
||||
********************************************************************************/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
problems "github.com/onyx-and-iris/aoc{{ .Scaffold.year }}/{{ .Project }}"
|
||||
)
|
||||
|
||||
//go:embed testdata
|
||||
var files embed.FS
|
||||
|
||||
func main() {
|
||||
filename := flag.String("f", "input.txt", "input file")
|
||||
loglevel := flag.Int("l", int(log.InfoLevel), "log level")
|
||||
flag.Parse()
|
||||
|
||||
if slices.Contains(log.AllLevels, log.Level(*loglevel)) {
|
||||
log.SetLevel(log.Level(*loglevel))
|
||||
}
|
||||
|
||||
data, err := files.ReadFile(fmt.Sprintf("testdata/%s", *filename))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
one, two, err := problems.Solve(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("solution one: %d\nsolution two: %d\n", one, two)
|
||||
}
|
||||
13
.scaffold/aoc/{{ .Project }}/internal/one/solve.go
Normal file
13
.scaffold/aoc/{{ .Project }}/internal/one/solve.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package one
|
||||
|
||||
import "bytes"
|
||||
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/input.txt
|
||||
var inputBuf []byte
|
||||
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(inputBuf)
|
||||
}
|
||||
18
.scaffold/aoc/{{ .Project }}/internal/one/util.go
Normal file
18
.scaffold/aoc/{{ .Project }}/internal/one/util.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
)
|
||||
|
||||
func parseLines(r io.Reader) error {
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
13
.scaffold/aoc/{{ .Project }}/internal/two/solve.go
Normal file
13
.scaffold/aoc/{{ .Project }}/internal/two/solve.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package two
|
||||
|
||||
import "bytes"
|
||||
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/input.txt
|
||||
var inputBuf []byte
|
||||
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(inputBuf)
|
||||
}
|
||||
18
.scaffold/aoc/{{ .Project }}/internal/two/util.go
Normal file
18
.scaffold/aoc/{{ .Project }}/internal/two/util.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
)
|
||||
|
||||
func parseLines(r io.Reader) error {
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
33
.scaffold/aoc/{{ .Project }}/makefile
Normal file
33
.scaffold/aoc/{{ .Project }}/makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
program = {{ .Project }}
|
||||
|
||||
GO = go
|
||||
CLI_DIR := cmd/cli
|
||||
BIN_DIR := bin
|
||||
|
||||
EXE := $(BIN_DIR)/$(program)
|
||||
|
||||
.DEFAULT_GOAL := build
|
||||
|
||||
.PHONY: fmt vet build test bench clean
|
||||
fmt:
|
||||
$(GO) fmt ./...
|
||||
|
||||
vet: fmt
|
||||
$(GO) vet ./...
|
||||
|
||||
build: vet | $(BIN_DIR)
|
||||
$(GO) build -o $(EXE) ./$(CLI_DIR)
|
||||
|
||||
test:
|
||||
$(GO) test ./...
|
||||
|
||||
bench:
|
||||
$(GO) test ./internal/one/ -bench=. > internal/one/benchmark
|
||||
$(GO) test ./internal/two/ -bench=. > internal/two/benchmark
|
||||
$(GO) test . -count=10 -bench=. > benchmark
|
||||
|
||||
$(BIN_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
clean:
|
||||
@rm -rv $(BIN_DIR)
|
||||
20
.scaffold/aoc/{{ .Project }}/solve.go
Normal file
20
.scaffold/aoc/{{ .Project }}/solve.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package solutions
|
||||
|
||||
import (
|
||||
"github.com/onyx-and-iris/aoc{{ .Scaffold.year }}/{{ .Project }}/internal/one"
|
||||
"github.com/onyx-and-iris/aoc{{ .Scaffold.year }}/{{ .Project }}/internal/two"
|
||||
)
|
||||
|
||||
func Solve(buf []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
answerTwo, err := two.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return answerOne, answerTwo, nil
|
||||
}
|
||||
15
.scaffold/aoc/{{ .Project }}/solve_internal_test.go
Normal file
15
.scaffold/aoc/{{ .Project }}/solve_internal_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package solutions
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/input.txt
|
||||
var inputBuf []byte
|
||||
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(inputBuf)
|
||||
}
|
||||
14
Pipfile
Normal file
14
Pipfile
Normal file
@@ -0,0 +1,14 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
matplotlib = "*"
|
||||
networkx = "*"
|
||||
pygraphviz = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.12"
|
||||
463
Pipfile.lock
generated
Normal file
463
Pipfile.lock
generated
Normal file
@@ -0,0 +1,463 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "cd5ccde9936751e89403473be8778f33b5b8e28ea76d00e6172b32bd58a7cdaf"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.12"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"contourpy": {
|
||||
"hashes": [
|
||||
"sha256:041b640d4ec01922083645a94bb3b2e777e6b626788f4095cf21abbe266413c1",
|
||||
"sha256:05e806338bfeaa006acbdeba0ad681a10be63b26e1b17317bfac3c5d98f36cda",
|
||||
"sha256:08d9d449a61cf53033612cb368f3a1b26cd7835d9b8cd326647efe43bca7568d",
|
||||
"sha256:0ffa84be8e0bd33410b17189f7164c3589c229ce5db85798076a3fa136d0e509",
|
||||
"sha256:113231fe3825ebf6f15eaa8bc1f5b0ddc19d42b733345eae0934cb291beb88b6",
|
||||
"sha256:14c102b0eab282427b662cb590f2e9340a9d91a1c297f48729431f2dcd16e14f",
|
||||
"sha256:174e758c66bbc1c8576992cec9599ce8b6672b741b5d336b5c74e35ac382b18e",
|
||||
"sha256:19c1555a6801c2f084c7ddc1c6e11f02eb6a6016ca1318dd5452ba3f613a1751",
|
||||
"sha256:19d40d37c1c3a4961b4619dd9d77b12124a453cc3d02bb31a07d58ef684d3d86",
|
||||
"sha256:1bf98051f1045b15c87868dbaea84f92408337d4f81d0e449ee41920ea121d3b",
|
||||
"sha256:20914c8c973f41456337652a6eeca26d2148aa96dd7ac323b74516988bea89fc",
|
||||
"sha256:287ccc248c9e0d0566934e7d606201abd74761b5703d804ff3df8935f523d546",
|
||||
"sha256:2ba94a401342fc0f8b948e57d977557fbf4d515f03c67682dd5c6191cb2d16ec",
|
||||
"sha256:31c1b55c1f34f80557d3830d3dd93ba722ce7e33a0b472cba0ec3b6535684d8f",
|
||||
"sha256:36987a15e8ace5f58d4d5da9dca82d498c2bbb28dff6e5d04fbfcc35a9cb3a82",
|
||||
"sha256:3a04ecd68acbd77fa2d39723ceca4c3197cb2969633836ced1bea14e219d077c",
|
||||
"sha256:3e8b974d8db2c5610fb4e76307e265de0edb655ae8169e8b21f41807ccbeec4b",
|
||||
"sha256:3ea9924d28fc5586bf0b42d15f590b10c224117e74409dd7a0be3b62b74a501c",
|
||||
"sha256:4318af1c925fb9a4fb190559ef3eec206845f63e80fb603d47f2d6d67683901c",
|
||||
"sha256:44a29502ca9c7b5ba389e620d44f2fbe792b1fb5734e8b931ad307071ec58c53",
|
||||
"sha256:47734d7073fb4590b4a40122b35917cd77be5722d80683b249dac1de266aac80",
|
||||
"sha256:4d76d5993a34ef3df5181ba3c92fabb93f1eaa5729504fb03423fcd9f3177242",
|
||||
"sha256:4dbbc03a40f916a8420e420d63e96a1258d3d1b58cbdfd8d1f07b49fcbd38e85",
|
||||
"sha256:500360b77259914f7805af7462e41f9cb7ca92ad38e9f94d6c8641b089338124",
|
||||
"sha256:523a8ee12edfa36f6d2a49407f705a6ef4c5098de4f498619787e272de93f2d5",
|
||||
"sha256:573abb30e0e05bf31ed067d2f82500ecfdaec15627a59d63ea2d95714790f5c2",
|
||||
"sha256:5b75aa69cb4d6f137b36f7eb2ace9280cfb60c55dc5f61c731fdf6f037f958a3",
|
||||
"sha256:61332c87493b00091423e747ea78200659dc09bdf7fd69edd5e98cef5d3e9a8d",
|
||||
"sha256:805617228ba7e2cbbfb6c503858e626ab528ac2a32a04a2fe88ffaf6b02c32bc",
|
||||
"sha256:841ad858cff65c2c04bf93875e384ccb82b654574a6d7f30453a04f04af71342",
|
||||
"sha256:89785bb2a1980c1bd87f0cb1517a71cde374776a5f150936b82580ae6ead44a1",
|
||||
"sha256:8eb96e79b9f3dcadbad2a3891672f81cdcab7f95b27f28f1c67d75f045b6b4f1",
|
||||
"sha256:974d8145f8ca354498005b5b981165b74a195abfae9a8129df3e56771961d595",
|
||||
"sha256:9ddeb796389dadcd884c7eb07bd14ef12408aaae358f0e2ae24114d797eede30",
|
||||
"sha256:a045f341a77b77e1c5de31e74e966537bba9f3c4099b35bf4c2e3939dd54cdab",
|
||||
"sha256:a0cffcbede75c059f535725c1680dfb17b6ba8753f0c74b14e6a9c68c29d7ea3",
|
||||
"sha256:a761d9ccfc5e2ecd1bf05534eda382aa14c3e4f9205ba5b1684ecfe400716ef2",
|
||||
"sha256:a7895f46d47671fa7ceec40f31fae721da51ad34bdca0bee83e38870b1f47ffd",
|
||||
"sha256:a9fa36448e6a3a1a9a2ba23c02012c43ed88905ec80163f2ffe2421c7192a5d7",
|
||||
"sha256:ab29962927945d89d9b293eabd0d59aea28d887d4f3be6c22deaefbb938a7277",
|
||||
"sha256:abbb49fb7dac584e5abc6636b7b2a7227111c4f771005853e7d25176daaf8453",
|
||||
"sha256:ac4578ac281983f63b400f7fe6c101bedc10651650eef012be1ccffcbacf3697",
|
||||
"sha256:adce39d67c0edf383647a3a007de0a45fd1b08dedaa5318404f1a73059c2512b",
|
||||
"sha256:ade08d343436a94e633db932e7e8407fe7de8083967962b46bdfc1b0ced39454",
|
||||
"sha256:b2bdca22a27e35f16794cf585832e542123296b4687f9fd96822db6bae17bfc9",
|
||||
"sha256:b2f926efda994cdf3c8d3fdb40b9962f86edbc4457e739277b961eced3d0b4c1",
|
||||
"sha256:b457d6430833cee8e4b8e9b6f07aa1c161e5e0d52e118dc102c8f9bd7dd060d6",
|
||||
"sha256:c414fc1ed8ee1dbd5da626cf3710c6013d3d27456651d156711fa24f24bd1291",
|
||||
"sha256:cb76c1a154b83991a3cbbf0dfeb26ec2833ad56f95540b442c73950af2013750",
|
||||
"sha256:dfd97abd83335045a913e3bcc4a09c0ceadbe66580cf573fe961f4a825efa699",
|
||||
"sha256:e914a8cb05ce5c809dd0fe350cfbb4e881bde5e2a38dc04e3afe1b3e58bd158e",
|
||||
"sha256:ece6df05e2c41bd46776fbc712e0996f7c94e0d0543af1656956d150c4ca7c81",
|
||||
"sha256:efa874e87e4a647fd2e4f514d5e91c7d493697127beb95e77d2f7561f6905bd9",
|
||||
"sha256:f611e628ef06670df83fce17805c344710ca5cde01edfdc72751311da8585375"
|
||||
],
|
||||
"markers": "python_version >= '3.10'",
|
||||
"version": "==1.3.1"
|
||||
},
|
||||
"cycler": {
|
||||
"hashes": [
|
||||
"sha256:85cef7cff222d8644161529808465972e51340599459b8ac3ccbac5a854e0d30",
|
||||
"sha256:88bb128f02ba341da8ef447245a9e138fae777f6a23943da4540077d3601eb1c"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==0.12.1"
|
||||
},
|
||||
"fonttools": {
|
||||
"hashes": [
|
||||
"sha256:07f8288aacf0a38d174445fc78377a97fb0b83cfe352a90c9d9c1400571963c7",
|
||||
"sha256:11e5de1ee0d95af4ae23c1a138b184b7f06e0b6abacabf1d0db41c90b03d834b",
|
||||
"sha256:1bc7ad24ff98846282eef1cbeac05d013c2154f977a79886bb943015d2b1b261",
|
||||
"sha256:1dcc07934a2165ccdc3a5a608db56fb3c24b609658a5b340aee4ecf3ba679dc0",
|
||||
"sha256:22f38464daa6cdb7b6aebd14ab06609328fe1e9705bb0fcc7d1e69de7109ee02",
|
||||
"sha256:27e4ae3592e62eba83cd2c4ccd9462dcfa603ff78e09110680a5444c6925d841",
|
||||
"sha256:3983313c2a04d6cc1fe9251f8fc647754cf49a61dac6cb1e7249ae67afaafc45",
|
||||
"sha256:529cef2ce91dc44f8e407cc567fae6e49a1786f2fefefa73a294704c415322a4",
|
||||
"sha256:5323a22eabddf4b24f66d26894f1229261021dacd9d29e89f7872dd8c63f0b8b",
|
||||
"sha256:54153c49913f45065c8d9e6d0c101396725c5621c8aee744719300f79771d75a",
|
||||
"sha256:546565028e244a701f73df6d8dd6be489d01617863ec0c6a42fa25bf45d43048",
|
||||
"sha256:5480673f599ad410695ca2ddef2dfefe9df779a9a5cda89503881e503c9c7d90",
|
||||
"sha256:5e8d657cd7326eeaba27de2740e847c6b39dde2f8d7cd7cc56f6aad404ddf0bd",
|
||||
"sha256:62d65a3022c35e404d19ca14f291c89cc5890032ff04f6c17af0bd1927299674",
|
||||
"sha256:6314bf82c54c53c71805318fcf6786d986461622dd926d92a465199ff54b1b72",
|
||||
"sha256:7a8aa2c5e5b8b3bcb2e4538d929f6589a5c6bdb84fd16e2ed92649fb5454f11c",
|
||||
"sha256:827e95fdbbd3e51f8b459af5ea10ecb4e30af50221ca103bea68218e9615de07",
|
||||
"sha256:859c358ebf41db18fb72342d3080bce67c02b39e86b9fbcf1610cca14984841b",
|
||||
"sha256:86721fbc389ef5cc1e2f477019e5069e8e4421e8d9576e9c26f840dbb04678de",
|
||||
"sha256:89bdc5d88bdeec1b15af790810e267e8332d92561dce4f0748c2b95c9bdf3926",
|
||||
"sha256:8c4491699bad88efe95772543cd49870cf756b019ad56294f6498982408ab03e",
|
||||
"sha256:8c5ec45428edaa7022f1c949a632a6f298edc7b481312fc7dc258921e9399628",
|
||||
"sha256:8e75f12c82127486fac2d8bfbf5bf058202f54bf4f158d367e41647b972342ca",
|
||||
"sha256:a430178ad3e650e695167cb53242dae3477b35c95bef6525b074d87493c4bf29",
|
||||
"sha256:a8c2794ded89399cc2169c4d0bf7941247b8d5932b2659e09834adfbb01589aa",
|
||||
"sha256:aca318b77f23523309eec4475d1fbbb00a6b133eb766a8bdc401faba91261abe",
|
||||
"sha256:ae3b6600565b2d80b7c05acb8e24d2b26ac407b27a3f2e078229721ba5698427",
|
||||
"sha256:aedbeb1db64496d098e6be92b2e63b5fac4e53b1b92032dfc6988e1ea9134a4d",
|
||||
"sha256:aee3b57643827e237ff6ec6d28d9ff9766bd8b21e08cd13bff479e13d4b14765",
|
||||
"sha256:b54baf65c52952db65df39fcd4820668d0ef4766c0ccdf32879b77f7c804d5c5",
|
||||
"sha256:b586ab5b15b6097f2fb71cafa3c98edfd0dba1ad8027229e7b1e204a58b0e09d",
|
||||
"sha256:b8d5e8916c0970fbc0f6f1bece0063363bb5857a7f170121a4493e31c3db3314",
|
||||
"sha256:bc5dbb4685e51235ef487e4bd501ddfc49be5aede5e40f4cefcccabc6e60fb4b",
|
||||
"sha256:bdcc9f04b36c6c20978d3f060e5323a43f6222accc4e7fcbef3f428e216d96af",
|
||||
"sha256:c3ca99e0d460eff46e033cd3992a969658c3169ffcd533e0a39c63a38beb6831",
|
||||
"sha256:caf8230f3e10f8f5d7593eb6d252a37caf58c480b19a17e250a63dad63834cf3",
|
||||
"sha256:cd70de1a52a8ee2d1877b6293af8a2484ac82514f10b1c67c1c5762d38073e56",
|
||||
"sha256:cf4fe7c124aa3f4e4c1940880156e13f2f4d98170d35c749e6b4f119a872551e",
|
||||
"sha256:d342e88764fb201286d185093781bf6628bbe380a913c24adf772d901baa8276",
|
||||
"sha256:da9da6d65cd7aa6b0f806556f4985bcbf603bf0c5c590e61b43aa3e5a0f822d0",
|
||||
"sha256:dc5294a3d5c84226e3dbba1b6f61d7ad813a8c0238fceea4e09aa04848c3d851",
|
||||
"sha256:dd68c87a2bfe37c5b33bcda0fba39b65a353876d3b9006fde3adae31f97b3ef5",
|
||||
"sha256:e6e8766eeeb2de759e862004aa11a9ea3d6f6d5ec710551a88b476192b64fd54",
|
||||
"sha256:e894b5bd60d9f473bed7a8f506515549cc194de08064d829464088d23097331b",
|
||||
"sha256:eb6ca911c4c17eb51853143624d8dc87cdcdf12a711fc38bf5bd21521e79715f",
|
||||
"sha256:ed63959d00b61959b035c7d47f9313c2c1ece090ff63afea702fe86de00dbed4",
|
||||
"sha256:f412604ccbeee81b091b420272841e5ec5ef68967a9790e80bffd0e30b8e2977",
|
||||
"sha256:f7d66c15ba875432a2d2fb419523f5d3d347f91f48f57b8b08a2dfc3c39b8a3f",
|
||||
"sha256:f9e736f60f4911061235603a6119e72053073a12c6d7904011df2d8fad2c0e35",
|
||||
"sha256:fb594b5a99943042c702c550d5494bdd7577f6ef19b0bc73877c948a63184a32"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==4.55.3"
|
||||
},
|
||||
"kiwisolver": {
|
||||
"hashes": [
|
||||
"sha256:01c3d31902c7db5fb6182832713d3b4122ad9317c2c5877d0539227d96bb2e50",
|
||||
"sha256:034d2c891f76bd3edbdb3ea11140d8510dca675443da7304205a2eaa45d8334c",
|
||||
"sha256:085940635c62697391baafaaeabdf3dd7a6c3643577dde337f4d66eba021b2b8",
|
||||
"sha256:08e77738ed7538f036cd1170cbed942ef749137b1311fa2bbe2a7fda2f6bf3cc",
|
||||
"sha256:111793b232842991be367ed828076b03d96202c19221b5ebab421ce8bcad016f",
|
||||
"sha256:11e1022b524bd48ae56c9b4f9296bce77e15a2e42a502cceba602f804b32bb79",
|
||||
"sha256:151dffc4865e5fe6dafce5480fab84f950d14566c480c08a53c663a0020504b6",
|
||||
"sha256:16523b40aab60426ffdebe33ac374457cf62863e330a90a0383639ce14bf44b2",
|
||||
"sha256:1732e065704b47c9afca7ffa272f845300a4eb959276bf6970dc07265e73b605",
|
||||
"sha256:1c8ceb754339793c24aee1c9fb2485b5b1f5bb1c2c214ff13368431e51fc9a09",
|
||||
"sha256:23454ff084b07ac54ca8be535f4174170c1094a4cff78fbae4f73a4bcc0d4dab",
|
||||
"sha256:23d5f023bdc8c7e54eb65f03ca5d5bb25b601eac4d7f1a042888a1f45237987e",
|
||||
"sha256:257af1622860e51b1a9d0ce387bf5c2c4f36a90594cb9514f55b074bcc787cfc",
|
||||
"sha256:286b18e86682fd2217a48fc6be6b0f20c1d0ed10958d8dc53453ad58d7be0bf8",
|
||||
"sha256:291331973c64bb9cce50bbe871fb2e675c4331dab4f31abe89f175ad7679a4d7",
|
||||
"sha256:2f0121b07b356a22fb0414cec4666bbe36fd6d0d759db3d37228f496ed67c880",
|
||||
"sha256:3452046c37c7692bd52b0e752b87954ef86ee2224e624ef7ce6cb21e8c41cc1b",
|
||||
"sha256:34d142fba9c464bc3bbfeff15c96eab0e7310343d6aefb62a79d51421fcc5f1b",
|
||||
"sha256:369b75d40abedc1da2c1f4de13f3482cb99e3237b38726710f4a793432b1c5ff",
|
||||
"sha256:36dbbfd34838500a31f52c9786990d00150860e46cd5041386f217101350f0d3",
|
||||
"sha256:370fd2df41660ed4e26b8c9d6bbcad668fbe2560462cba151a721d49e5b6628c",
|
||||
"sha256:3a96c0e790ee875d65e340ab383700e2b4891677b7fcd30a699146f9384a2bb0",
|
||||
"sha256:3b9b4d2892fefc886f30301cdd80debd8bb01ecdf165a449eb6e78f79f0fabd6",
|
||||
"sha256:3cd3bc628b25f74aedc6d374d5babf0166a92ff1317f46267f12d2ed54bc1d30",
|
||||
"sha256:3ddc373e0eef45b59197de815b1b28ef89ae3955e7722cc9710fb91cd77b7f47",
|
||||
"sha256:4191ee8dfd0be1c3666ccbac178c5a05d5f8d689bbe3fc92f3c4abec817f8fe0",
|
||||
"sha256:54a62808ac74b5e55a04a408cda6156f986cefbcf0ada13572696b507cc92fa1",
|
||||
"sha256:577facaa411c10421314598b50413aa1ebcf5126f704f1e5d72d7e4e9f020d90",
|
||||
"sha256:641f2ddf9358c80faa22e22eb4c9f54bd3f0e442e038728f500e3b978d00aa7d",
|
||||
"sha256:65ea09a5a3faadd59c2ce96dc7bf0f364986a315949dc6374f04396b0d60e09b",
|
||||
"sha256:68269e60ee4929893aad82666821aaacbd455284124817af45c11e50a4b42e3c",
|
||||
"sha256:69b5637c3f316cab1ec1c9a12b8c5f4750a4c4b71af9157645bf32830e39c03a",
|
||||
"sha256:7506488470f41169b86d8c9aeff587293f530a23a23a49d6bc64dab66bedc71e",
|
||||
"sha256:768cade2c2df13db52475bd28d3a3fac8c9eff04b0e9e2fda0f3760f20b3f7fc",
|
||||
"sha256:77e6f57a20b9bd4e1e2cedda4d0b986ebd0216236f0106e55c28aea3d3d69b16",
|
||||
"sha256:782bb86f245ec18009890e7cb8d13a5ef54dcf2ebe18ed65f795e635a96a1c6a",
|
||||
"sha256:7a3ad337add5148cf51ce0b55642dc551c0b9d6248458a757f98796ca7348712",
|
||||
"sha256:7cd2785b9391f2873ad46088ed7599a6a71e762e1ea33e87514b1a441ed1da1c",
|
||||
"sha256:7e9a60b50fe8b2ec6f448fe8d81b07e40141bfced7f896309df271a0b92f80f3",
|
||||
"sha256:84a2f830d42707de1d191b9490ac186bf7997a9495d4e9072210a1296345f7dc",
|
||||
"sha256:856b269c4d28a5c0d5e6c1955ec36ebfd1651ac00e1ce0afa3e28da95293b561",
|
||||
"sha256:858416b7fb777a53f0c59ca08190ce24e9abbd3cffa18886a5781b8e3e26f65d",
|
||||
"sha256:87b287251ad6488e95b4f0b4a79a6d04d3ea35fde6340eb38fbd1ca9cd35bbbc",
|
||||
"sha256:88c6f252f6816a73b1f8c904f7bbe02fd67c09a69f7cb8a0eecdbf5ce78e63db",
|
||||
"sha256:893f5525bb92d3d735878ec00f781b2de998333659507d29ea4466208df37bed",
|
||||
"sha256:89c107041f7b27844179ea9c85d6da275aa55ecf28413e87624d033cf1f6b751",
|
||||
"sha256:918139571133f366e8362fa4a297aeba86c7816b7ecf0bc79168080e2bd79957",
|
||||
"sha256:99cea8b9dd34ff80c521aef46a1dddb0dcc0283cf18bde6d756f1e6f31772165",
|
||||
"sha256:a17b7c4f5b2c51bb68ed379defd608a03954a1845dfed7cc0117f1cc8a9b7fd2",
|
||||
"sha256:a3c44cb68861de93f0c4a8175fbaa691f0aa22550c331fefef02b618a9dcb476",
|
||||
"sha256:a4d3601908c560bdf880f07d94f31d734afd1bb71e96585cace0e38ef44c6d84",
|
||||
"sha256:a5ce1e481a74b44dd5e92ff03ea0cb371ae7a0268318e202be06c8f04f4f1246",
|
||||
"sha256:a66f60f8d0c87ab7f59b6fb80e642ebb29fec354a4dfad687ca4092ae69d04f4",
|
||||
"sha256:b21dbe165081142b1232a240fc6383fd32cdd877ca6cc89eab93e5f5883e1c25",
|
||||
"sha256:b47a465040146981dc9db8647981b8cb96366fbc8d452b031e4f8fdffec3f26d",
|
||||
"sha256:b5773efa2be9eb9fcf5415ea3ab70fc785d598729fd6057bea38d539ead28271",
|
||||
"sha256:b83dc6769ddbc57613280118fb4ce3cd08899cc3369f7d0e0fab518a7cf37fdb",
|
||||
"sha256:bade438f86e21d91e0cf5dd7c0ed00cda0f77c8c1616bd83f9fc157fa6760d31",
|
||||
"sha256:bcb1ebc3547619c3b58a39e2448af089ea2ef44b37988caf432447374941574e",
|
||||
"sha256:be4816dc51c8a471749d664161b434912eee82f2ea66bd7628bd14583a833e85",
|
||||
"sha256:c07b29089b7ba090b6f1a669f1411f27221c3662b3a1b7010e67b59bb5a6f10b",
|
||||
"sha256:c2b9a96e0f326205af81a15718a9073328df1173a2619a68553decb7097fd5d7",
|
||||
"sha256:c5020c83e8553f770cb3b5fc13faac40f17e0b205bd237aebd21d53d733adb03",
|
||||
"sha256:c72941acb7b67138f35b879bbe85be0f6c6a70cab78fe3ef6db9c024d9223e5b",
|
||||
"sha256:c8bf637892dc6e6aad2bc6d4d69d08764166e5e3f69d469e55427b6ac001b19d",
|
||||
"sha256:cc978a80a0db3a66d25767b03688f1147a69e6237175c0f4ffffaaedf744055a",
|
||||
"sha256:ce2cf1e5688edcb727fdf7cd1bbd0b6416758996826a8be1d958f91880d0809d",
|
||||
"sha256:d47b28d1dfe0793d5e96bce90835e17edf9a499b53969b03c6c47ea5985844c3",
|
||||
"sha256:d47cfb2650f0e103d4bf68b0b5804c68da97272c84bb12850d877a95c056bd67",
|
||||
"sha256:d5536185fce131780ebd809f8e623bf4030ce1b161353166c49a3c74c287897f",
|
||||
"sha256:d561d2d8883e0819445cfe58d7ddd673e4015c3c57261d7bdcd3710d0d14005c",
|
||||
"sha256:d6af5e8815fd02997cb6ad9bbed0ee1e60014438ee1a5c2444c96f87b8843502",
|
||||
"sha256:d6d6bd87df62c27d4185de7c511c6248040afae67028a8a22012b010bc7ad062",
|
||||
"sha256:dace81d28c787956bfbfbbfd72fdcef014f37d9b48830829e488fdb32b49d954",
|
||||
"sha256:e063ef9f89885a1d68dd8b2e18f5ead48653176d10a0e324e3b0030e3a69adeb",
|
||||
"sha256:e7a019419b7b510f0f7c9dceff8c5eae2392037eae483a7f9162625233802b0a",
|
||||
"sha256:eaa973f1e05131de5ff3569bbba7f5fd07ea0595d3870ed4a526d486fe57fa1b",
|
||||
"sha256:eb158fe28ca0c29f2260cca8c43005329ad58452c36f0edf298204de32a9a3ed",
|
||||
"sha256:ed33ca2002a779a2e20eeb06aea7721b6e47f2d4b8a8ece979d8ba9e2a167e34",
|
||||
"sha256:fc2ace710ba7c1dfd1a3b42530b62b9ceed115f19a1656adefce7b1782a37794"
|
||||
],
|
||||
"markers": "python_version >= '3.10'",
|
||||
"version": "==1.4.8"
|
||||
},
|
||||
"matplotlib": {
|
||||
"hashes": [
|
||||
"sha256:01d2b19f13aeec2e759414d3bfe19ddfb16b13a1250add08d46d5ff6f9be83c6",
|
||||
"sha256:12eaf48463b472c3c0f8dbacdbf906e573013df81a0ab82f0616ea4b11281908",
|
||||
"sha256:2c5829a5a1dd5a71f0e31e6e8bb449bc0ee9dbfb05ad28fc0c6b55101b3a4be6",
|
||||
"sha256:2fbbabc82fde51391c4da5006f965e36d86d95f6ee83fb594b279564a4c5d0d2",
|
||||
"sha256:3547d153d70233a8496859097ef0312212e2689cdf8d7ed764441c77604095ae",
|
||||
"sha256:359f87baedb1f836ce307f0e850d12bb5f1936f70d035561f90d41d305fdacea",
|
||||
"sha256:3b427392354d10975c1d0f4ee18aa5844640b512d5311ef32efd4dd7db106ede",
|
||||
"sha256:4659665bc7c9b58f8c00317c3c2a299f7f258eeae5a5d56b4c64226fca2f7c59",
|
||||
"sha256:4673ff67a36152c48ddeaf1135e74ce0d4bce1bbf836ae40ed39c29edf7e2765",
|
||||
"sha256:503feb23bd8c8acc75541548a1d709c059b7184cde26314896e10a9f14df5f12",
|
||||
"sha256:5439f4c5a3e2e8eab18e2f8c3ef929772fd5641876db71f08127eed95ab64683",
|
||||
"sha256:5cdbaf909887373c3e094b0318d7ff230b2ad9dcb64da7ade654182872ab2593",
|
||||
"sha256:5e6c6461e1fc63df30bf6f80f0b93f5b6784299f721bc28530477acd51bfc3d1",
|
||||
"sha256:5fd41b0ec7ee45cd960a8e71aea7c946a28a0b8a4dcee47d2856b2af051f334c",
|
||||
"sha256:607b16c8a73943df110f99ee2e940b8a1cbf9714b65307c040d422558397dac5",
|
||||
"sha256:7e8632baebb058555ac0cde75db885c61f1212e47723d63921879806b40bec6a",
|
||||
"sha256:81713dd0d103b379de4516b861d964b1d789a144103277769238c732229d7f03",
|
||||
"sha256:845d96568ec873be63f25fa80e9e7fae4be854a66a7e2f0c8ccc99e94a8bd4ef",
|
||||
"sha256:95b710fea129c76d30be72c3b38f330269363fbc6e570a5dd43580487380b5ff",
|
||||
"sha256:96f2886f5c1e466f21cc41b70c5a0cd47bfa0015eb2d5793c88ebce658600e25",
|
||||
"sha256:994c07b9d9fe8d25951e3202a68c17900679274dadfc1248738dcfa1bd40d7f3",
|
||||
"sha256:9ade1003376731a971e398cc4ef38bb83ee8caf0aee46ac6daa4b0506db1fd06",
|
||||
"sha256:9b0558bae37f154fffda54d779a592bc97ca8b4701f1c710055b609a3bac44c8",
|
||||
"sha256:a2a43cbefe22d653ab34bb55d42384ed30f611bcbdea1f8d7f431011a2e1c62e",
|
||||
"sha256:a994f29e968ca002b50982b27168addfd65f0105610b6be7fa515ca4b5307c95",
|
||||
"sha256:ad2e15300530c1a94c63cfa546e3b7864bd18ea2901317bae8bbf06a5ade6dcf",
|
||||
"sha256:ae80dc3a4add4665cf2faa90138384a7ffe2a4e37c58d83e115b54287c4f06ef",
|
||||
"sha256:b886d02a581b96704c9d1ffe55709e49b4d2d52709ccebc4be42db856e511278",
|
||||
"sha256:c40ba2eb08b3f5de88152c2333c58cee7edcead0a2a0d60fcafa116b17117adc",
|
||||
"sha256:c55b20591ced744aa04e8c3e4b7543ea4d650b6c3c4b208c08a05b4010e8b442",
|
||||
"sha256:c58a9622d5dbeb668f407f35f4e6bfac34bb9ecdcc81680c04d0258169747997",
|
||||
"sha256:d44cb942af1693cced2604c33a9abcef6205601c445f6d0dc531d813af8a2f5a",
|
||||
"sha256:d907fddb39f923d011875452ff1eca29a9e7f21722b873e90db32e5d8ddff12e",
|
||||
"sha256:fd44fc75522f58612ec4a33958a7e5552562b7705b42ef1b4f8c0818e304a363"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.10'",
|
||||
"version": "==3.10.0"
|
||||
},
|
||||
"networkx": {
|
||||
"hashes": [
|
||||
"sha256:307c3669428c5362aab27c8a1260aa8f47c4e91d3891f48be0141738d8d053e1",
|
||||
"sha256:df5d4365b724cf81b8c6a7312509d0c22386097011ad1abe274afd5e9d3bbc5f"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.10'",
|
||||
"version": "==3.4.2"
|
||||
},
|
||||
"numpy": {
|
||||
"hashes": [
|
||||
"sha256:059e6a747ae84fce488c3ee397cee7e5f905fd1bda5fb18c66bc41807ff119b2",
|
||||
"sha256:08ef779aed40dbc52729d6ffe7dd51df85796a702afbf68a4f4e41fafdc8bda5",
|
||||
"sha256:164a829b6aacf79ca47ba4814b130c4020b202522a93d7bff2202bfb33b61c60",
|
||||
"sha256:26c9c4382b19fcfbbed3238a14abf7ff223890ea1936b8890f058e7ba35e8d71",
|
||||
"sha256:27f5cdf9f493b35f7e41e8368e7d7b4bbafaf9660cba53fb21d2cd174ec09631",
|
||||
"sha256:31b89fa67a8042e96715c68e071a1200c4e172f93b0fbe01a14c0ff3ff820fc8",
|
||||
"sha256:32cb94448be47c500d2c7a95f93e2f21a01f1fd05dd2beea1ccd049bb6001cd2",
|
||||
"sha256:360137f8fb1b753c5cde3ac388597ad680eccbbbb3865ab65efea062c4a1fd16",
|
||||
"sha256:3683a8d166f2692664262fd4900f207791d005fb088d7fdb973cc8d663626faa",
|
||||
"sha256:38efc1e56b73cc9b182fe55e56e63b044dd26a72128fd2fbd502f75555d92591",
|
||||
"sha256:3d03883435a19794e41f147612a77a8f56d4e52822337844fff3d4040a142964",
|
||||
"sha256:3ecc47cd7f6ea0336042be87d9e7da378e5c7e9b3c8ad0f7c966f714fc10d821",
|
||||
"sha256:40f9e544c1c56ba8f1cf7686a8c9b5bb249e665d40d626a23899ba6d5d9e1484",
|
||||
"sha256:4250888bcb96617e00bfa28ac24850a83c9f3a16db471eca2ee1f1714df0f957",
|
||||
"sha256:4511d9e6071452b944207c8ce46ad2f897307910b402ea5fa975da32e0102800",
|
||||
"sha256:45681fd7128c8ad1c379f0ca0776a8b0c6583d2f69889ddac01559dfe4390918",
|
||||
"sha256:48fd472630715e1c1c89bf1feab55c29098cb403cc184b4859f9c86d4fcb6a95",
|
||||
"sha256:4c86e2a209199ead7ee0af65e1d9992d1dce7e1f63c4b9a616500f93820658d0",
|
||||
"sha256:4dfda918a13cc4f81e9118dea249e192ab167a0bb1966272d5503e39234d694e",
|
||||
"sha256:5062dc1a4e32a10dc2b8b13cedd58988261416e811c1dc4dbdea4f57eea61b0d",
|
||||
"sha256:51faf345324db860b515d3f364eaa93d0e0551a88d6218a7d61286554d190d73",
|
||||
"sha256:526fc406ab991a340744aad7e25251dd47a6720a685fa3331e5c59fef5282a59",
|
||||
"sha256:53c09385ff0b72ba79d8715683c1168c12e0b6e84fb0372e97553d1ea91efe51",
|
||||
"sha256:55ba24ebe208344aa7a00e4482f65742969a039c2acfcb910bc6fcd776eb4355",
|
||||
"sha256:5b6c390bfaef8c45a260554888966618328d30e72173697e5cabe6b285fb2348",
|
||||
"sha256:5c5cc0cbabe9452038ed984d05ac87910f89370b9242371bd9079cb4af61811e",
|
||||
"sha256:5edb4e4caf751c1518e6a26a83501fda79bff41cc59dac48d70e6d65d4ec4440",
|
||||
"sha256:61048b4a49b1c93fe13426e04e04fdf5a03f456616f6e98c7576144677598675",
|
||||
"sha256:676f4eebf6b2d430300f1f4f4c2461685f8269f94c89698d832cdf9277f30b84",
|
||||
"sha256:67d4cda6fa6ffa073b08c8372aa5fa767ceb10c9a0587c707505a6d426f4e046",
|
||||
"sha256:694f9e921a0c8f252980e85bce61ebbd07ed2b7d4fa72d0e4246f2f8aa6642ab",
|
||||
"sha256:733585f9f4b62e9b3528dd1070ec4f52b8acf64215b60a845fa13ebd73cd0712",
|
||||
"sha256:7671dc19c7019103ca44e8d94917eba8534c76133523ca8406822efdd19c9308",
|
||||
"sha256:780077d95eafc2ccc3ced969db22377b3864e5b9a0ea5eb347cc93b3ea900315",
|
||||
"sha256:7ba9cc93a91d86365a5d270dee221fdc04fb68d7478e6bf6af650de78a8339e3",
|
||||
"sha256:89b16a18e7bba224ce5114db863e7029803c179979e1af6ad6a6b11f70545008",
|
||||
"sha256:9036d6365d13b6cbe8f27a0eaf73ddcc070cae584e5ff94bb45e3e9d729feab5",
|
||||
"sha256:93cf4e045bae74c90ca833cba583c14b62cb4ba2cba0abd2b141ab52548247e2",
|
||||
"sha256:9ad014faa93dbb52c80d8f4d3dcf855865c876c9660cb9bd7553843dd03a4b1e",
|
||||
"sha256:9b1d07b53b78bf84a96898c1bc139ad7f10fda7423f5fd158fd0f47ec5e01ac7",
|
||||
"sha256:a7746f235c47abc72b102d3bce9977714c2444bdfaea7888d241b4c4bb6a78bf",
|
||||
"sha256:aa3017c40d513ccac9621a2364f939d39e550c542eb2a894b4c8da92b38896ab",
|
||||
"sha256:b34d87e8a3090ea626003f87f9392b3929a7bbf4104a05b6667348b6bd4bf1cd",
|
||||
"sha256:b541032178a718c165a49638d28272b771053f628382d5e9d1c93df23ff58dbf",
|
||||
"sha256:ba5511d8f31c033a5fcbda22dd5c813630af98c70b2661f2d2c654ae3cdfcfc8",
|
||||
"sha256:bc8a37ad5b22c08e2dbd27df2b3ef7e5c0864235805b1e718a235bcb200cf1cb",
|
||||
"sha256:bff7d8ec20f5f42607599f9994770fa65d76edca264a87b5e4ea5629bce12268",
|
||||
"sha256:c1ad395cf254c4fbb5b2132fee391f361a6e8c1adbd28f2cd8e79308a615fe9d",
|
||||
"sha256:f1d09e520217618e76396377c81fba6f290d5f926f50c35f3a5f72b01a0da780",
|
||||
"sha256:f3eac17d9ec51be534685ba877b6ab5edc3ab7ec95c8f163e5d7b39859524716",
|
||||
"sha256:f419290bc8968a46c4933158c91a0012b7a99bb2e465d5ef5293879742f8797e",
|
||||
"sha256:f62aa6ee4eb43b024b0e5a01cf65a0bb078ef8c395e8713c6e8a12a697144528",
|
||||
"sha256:f74e6fdeb9a265624ec3a3918430205dff1df7e95a230779746a6af78bc615af",
|
||||
"sha256:f9b57eaa3b0cd8db52049ed0330747b0364e899e8a606a624813452b8203d5f7",
|
||||
"sha256:fce4f615f8ca31b2e61aa0eb5865a21e14f5629515c9151850aa936c02a1ee51"
|
||||
],
|
||||
"markers": "python_version >= '3.10'",
|
||||
"version": "==2.2.1"
|
||||
},
|
||||
"packaging": {
|
||||
"hashes": [
|
||||
"sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759",
|
||||
"sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==24.2"
|
||||
},
|
||||
"pillow": {
|
||||
"hashes": [
|
||||
"sha256:00177a63030d612148e659b55ba99527803288cea7c75fb05766ab7981a8c1b7",
|
||||
"sha256:006bcdd307cc47ba43e924099a038cbf9591062e6c50e570819743f5607404f5",
|
||||
"sha256:084a07ef0821cfe4858fe86652fffac8e187b6ae677e9906e192aafcc1b69903",
|
||||
"sha256:0ae08bd8ffc41aebf578c2af2f9d8749d91f448b3bfd41d7d9ff573d74f2a6b2",
|
||||
"sha256:0e038b0745997c7dcaae350d35859c9715c71e92ffb7e0f4a8e8a16732150f38",
|
||||
"sha256:1187739620f2b365de756ce086fdb3604573337cc28a0d3ac4a01ab6b2d2a6d2",
|
||||
"sha256:16095692a253047fe3ec028e951fa4221a1f3ed3d80c397e83541a3037ff67c9",
|
||||
"sha256:1a61b54f87ab5786b8479f81c4b11f4d61702830354520837f8cc791ebba0f5f",
|
||||
"sha256:1c1d72714f429a521d8d2d018badc42414c3077eb187a59579f28e4270b4b0fc",
|
||||
"sha256:1e2688958a840c822279fda0086fec1fdab2f95bf2b717b66871c4ad9859d7e8",
|
||||
"sha256:20ec184af98a121fb2da42642dea8a29ec80fc3efbaefb86d8fdd2606619045d",
|
||||
"sha256:21a0d3b115009ebb8ac3d2ebec5c2982cc693da935f4ab7bb5c8ebe2f47d36f2",
|
||||
"sha256:224aaa38177597bb179f3ec87eeefcce8e4f85e608025e9cfac60de237ba6316",
|
||||
"sha256:2679d2258b7f1192b378e2893a8a0a0ca472234d4c2c0e6bdd3380e8dfa21b6a",
|
||||
"sha256:27a7860107500d813fcd203b4ea19b04babe79448268403172782754870dac25",
|
||||
"sha256:290f2cc809f9da7d6d622550bbf4c1e57518212da51b6a30fe8e0a270a5b78bd",
|
||||
"sha256:2e46773dc9f35a1dd28bd6981332fd7f27bec001a918a72a79b4133cf5291dba",
|
||||
"sha256:3107c66e43bda25359d5ef446f59c497de2b5ed4c7fdba0894f8d6cf3822dafc",
|
||||
"sha256:375b8dd15a1f5d2feafff536d47e22f69625c1aa92f12b339ec0b2ca40263273",
|
||||
"sha256:45c566eb10b8967d71bf1ab8e4a525e5a93519e29ea071459ce517f6b903d7fa",
|
||||
"sha256:499c3a1b0d6fc8213519e193796eb1a86a1be4b1877d678b30f83fd979811d1a",
|
||||
"sha256:4ad70c4214f67d7466bea6a08061eba35c01b1b89eaa098040a35272a8efb22b",
|
||||
"sha256:4b60c9520f7207aaf2e1d94de026682fc227806c6e1f55bba7606d1c94dd623a",
|
||||
"sha256:5178952973e588b3f1360868847334e9e3bf49d19e169bbbdfaf8398002419ae",
|
||||
"sha256:52a2d8323a465f84faaba5236567d212c3668f2ab53e1c74c15583cf507a0291",
|
||||
"sha256:598b4e238f13276e0008299bd2482003f48158e2b11826862b1eb2ad7c768b97",
|
||||
"sha256:5bd2d3bdb846d757055910f0a59792d33b555800813c3b39ada1829c372ccb06",
|
||||
"sha256:5c39ed17edea3bc69c743a8dd3e9853b7509625c2462532e62baa0732163a904",
|
||||
"sha256:5d203af30149ae339ad1b4f710d9844ed8796e97fda23ffbc4cc472968a47d0b",
|
||||
"sha256:5ddbfd761ee00c12ee1be86c9c0683ecf5bb14c9772ddbd782085779a63dd55b",
|
||||
"sha256:607bbe123c74e272e381a8d1957083a9463401f7bd01287f50521ecb05a313f8",
|
||||
"sha256:61b887f9ddba63ddf62fd02a3ba7add935d053b6dd7d58998c630e6dbade8527",
|
||||
"sha256:6619654954dc4936fcff82db8eb6401d3159ec6be81e33c6000dfd76ae189947",
|
||||
"sha256:674629ff60030d144b7bca2b8330225a9b11c482ed408813924619c6f302fdbb",
|
||||
"sha256:6ec0d5af64f2e3d64a165f490d96368bb5dea8b8f9ad04487f9ab60dc4bb6003",
|
||||
"sha256:6f4dba50cfa56f910241eb7f883c20f1e7b1d8f7d91c750cd0b318bad443f4d5",
|
||||
"sha256:70fbbdacd1d271b77b7721fe3cdd2d537bbbd75d29e6300c672ec6bb38d9672f",
|
||||
"sha256:72bacbaf24ac003fea9bff9837d1eedb6088758d41e100c1552930151f677739",
|
||||
"sha256:7326a1787e3c7b0429659e0a944725e1b03eeaa10edd945a86dead1913383944",
|
||||
"sha256:73853108f56df97baf2bb8b522f3578221e56f646ba345a372c78326710d3830",
|
||||
"sha256:73e3a0200cdda995c7e43dd47436c1548f87a30bb27fb871f352a22ab8dcf45f",
|
||||
"sha256:75acbbeb05b86bc53cbe7b7e6fe00fbcf82ad7c684b3ad82e3d711da9ba287d3",
|
||||
"sha256:8069c5179902dcdce0be9bfc8235347fdbac249d23bd90514b7a47a72d9fecf4",
|
||||
"sha256:846e193e103b41e984ac921b335df59195356ce3f71dcfd155aa79c603873b84",
|
||||
"sha256:8594f42df584e5b4bb9281799698403f7af489fba84c34d53d1c4bfb71b7c4e7",
|
||||
"sha256:86510e3f5eca0ab87429dd77fafc04693195eec7fd6a137c389c3eeb4cfb77c6",
|
||||
"sha256:8853a3bf12afddfdf15f57c4b02d7ded92c7a75a5d7331d19f4f9572a89c17e6",
|
||||
"sha256:88a58d8ac0cc0e7f3a014509f0455248a76629ca9b604eca7dc5927cc593c5e9",
|
||||
"sha256:8ba470552b48e5835f1d23ecb936bb7f71d206f9dfeee64245f30c3270b994de",
|
||||
"sha256:8c676b587da5673d3c75bd67dd2a8cdfeb282ca38a30f37950511766b26858c4",
|
||||
"sha256:8ec4a89295cd6cd4d1058a5e6aec6bf51e0eaaf9714774e1bfac7cfc9051db47",
|
||||
"sha256:94f3e1780abb45062287b4614a5bc0874519c86a777d4a7ad34978e86428b8dd",
|
||||
"sha256:9a0f748eaa434a41fccf8e1ee7a3eed68af1b690e75328fd7a60af123c193b50",
|
||||
"sha256:a5629742881bcbc1f42e840af185fd4d83a5edeb96475a575f4da50d6ede337c",
|
||||
"sha256:a65149d8ada1055029fcb665452b2814fe7d7082fcb0c5bed6db851cb69b2086",
|
||||
"sha256:b3c5ac4bed7519088103d9450a1107f76308ecf91d6dabc8a33a2fcfb18d0fba",
|
||||
"sha256:b4fd7bd29610a83a8c9b564d457cf5bd92b4e11e79a4ee4716a63c959699b306",
|
||||
"sha256:bcd1fb5bb7b07f64c15618c89efcc2cfa3e95f0e3bcdbaf4642509de1942a699",
|
||||
"sha256:c12b5ae868897c7338519c03049a806af85b9b8c237b7d675b8c5e089e4a618e",
|
||||
"sha256:c26845094b1af3c91852745ae78e3ea47abf3dbcd1cf962f16b9a5fbe3ee8488",
|
||||
"sha256:c6a660307ca9d4867caa8d9ca2c2658ab685de83792d1876274991adec7b93fa",
|
||||
"sha256:c809a70e43c7977c4a42aefd62f0131823ebf7dd73556fa5d5950f5b354087e2",
|
||||
"sha256:c8b2351c85d855293a299038e1f89db92a2f35e8d2f783489c6f0b2b5f3fe8a3",
|
||||
"sha256:cb929ca942d0ec4fac404cbf520ee6cac37bf35be479b970c4ffadf2b6a1cad9",
|
||||
"sha256:d2c0a187a92a1cb5ef2c8ed5412dd8d4334272617f532d4ad4de31e0495bd923",
|
||||
"sha256:d69bfd8ec3219ae71bcde1f942b728903cad25fafe3100ba2258b973bd2bc1b2",
|
||||
"sha256:daffdf51ee5db69a82dd127eabecce20729e21f7a3680cf7cbb23f0829189790",
|
||||
"sha256:e58876c91f97b0952eb766123bfef372792ab3f4e3e1f1a2267834c2ab131734",
|
||||
"sha256:eda2616eb2313cbb3eebbe51f19362eb434b18e3bb599466a1ffa76a033fb916",
|
||||
"sha256:ee217c198f2e41f184f3869f3e485557296d505b5195c513b2bfe0062dc537f1",
|
||||
"sha256:f02541ef64077f22bf4924f225c0fd1248c168f86e4b7abdedd87d6ebaceab0f",
|
||||
"sha256:f1b82c27e89fffc6da125d5eb0ca6e68017faf5efc078128cfaa42cf5cb38798",
|
||||
"sha256:fba162b8872d30fea8c52b258a542c5dfd7b235fb5cb352240c8d63b414013eb",
|
||||
"sha256:fbbcb7b57dc9c794843e3d1258c0fbf0f48656d46ffe9e09b63bbd6e8cd5d0a2",
|
||||
"sha256:fcb4621042ac4b7865c179bb972ed0da0218a076dc1820ffc48b1d74c1e37fe9"
|
||||
],
|
||||
"markers": "python_version >= '3.9'",
|
||||
"version": "==11.0.0"
|
||||
},
|
||||
"pygraphviz": {
|
||||
"hashes": [
|
||||
"sha256:c10df02377f4e39b00ae17c862f4ee7e5767317f1c6b2dfd04cea6acc7fc2bea"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.10'",
|
||||
"version": "==1.14"
|
||||
},
|
||||
"pyparsing": {
|
||||
"hashes": [
|
||||
"sha256:93d9577b88da0bbea8cc8334ee8b918ed014968fd2ec383e868fb8afb1ccef84",
|
||||
"sha256:cbf74e27246d595d9a74b186b810f6fbb86726dbf3b9532efb343f6d7294fe9c"
|
||||
],
|
||||
"markers": "python_version >= '3.9'",
|
||||
"version": "==3.2.0"
|
||||
},
|
||||
"python-dateutil": {
|
||||
"hashes": [
|
||||
"sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3",
|
||||
"sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==2.9.0.post0"
|
||||
},
|
||||
"six": {
|
||||
"hashes": [
|
||||
"sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274",
|
||||
"sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==1.17.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
||||
@@ -2,14 +2,14 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-01
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkMain-12 1000000000 0.001576 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001731 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001616 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001597 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001559 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001657 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001542 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001561 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001574 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001582 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-01 0.126s
|
||||
BenchmarkSolve-12 1000000000 0.0007936 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007772 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007784 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008174 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008691 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007931 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007870 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007921 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007953 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007633 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-01 0.079s
|
||||
|
||||
@@ -2,5 +2,5 @@ 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
|
||||
BenchmarkSolve-12 1000000000 0.0002849 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-01/internal/one 0.007s
|
||||
|
||||
@@ -6,12 +6,10 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-01/internal/util"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
left, right, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -31,8 +29,8 @@ func parseLines(r io.Reader) ([]int, []int, error) {
|
||||
for scanner.Scan() {
|
||||
nums := strings.Fields(scanner.Text())
|
||||
|
||||
left = util.InsertSorted(left, util.MustConv(nums[0]))
|
||||
right = util.InsertSorted(right, util.MustConv(nums[1]))
|
||||
left = insertSorted(left, mustConv(nums[0]))
|
||||
right = insertSorted(right, mustConv(nums[1]))
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package util
|
||||
package one
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func MustConv(s string) int {
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -14,7 +14,7 @@ func MustConv(s string) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func InsertSorted[T cmp.Ordered](ts []T, t T) []T {
|
||||
func insertSorted[T cmp.Ordered](ts []T, t T) []T {
|
||||
i, _ := slices.BinarySearch(ts, t)
|
||||
return slices.Insert(ts, i, t)
|
||||
}
|
||||
@@ -2,5 +2,5 @@ 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
|
||||
BenchmarkSolve-12 1000000000 0.0005199 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-01/internal/two 0.009s
|
||||
|
||||
@@ -6,12 +6,10 @@ import (
|
||||
"io"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-01/internal/util"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
left, right, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -43,8 +41,8 @@ func parseLines(r io.Reader) (map[int]int, []int, error) {
|
||||
for scanner.Scan() {
|
||||
nums := strings.Fields(scanner.Text())
|
||||
|
||||
left[util.MustConv(nums[0])]++
|
||||
right = util.InsertSorted(right, util.MustConv(nums[1]))
|
||||
left[mustConv(nums[0])]++
|
||||
right = insertSorted(right, mustConv(nums[1]))
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
20
day-01/internal/two/util.go
Normal file
20
day-01/internal/two/util.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"slices"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func insertSorted[T cmp.Ordered](ts []T, t T) []T {
|
||||
i, _ := slices.BinarySearch(ts, t)
|
||||
return slices.Insert(ts, i, t)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
program = day-01
|
||||
|
||||
GO = go
|
||||
SRC_DIR := src
|
||||
CLI_DIR := cmd/cli
|
||||
BIN_DIR := bin
|
||||
|
||||
EXE := $(BIN_DIR)/$(program)
|
||||
@@ -16,7 +16,7 @@ vet: fmt
|
||||
$(GO) vet ./...
|
||||
|
||||
build: vet | $(BIN_DIR)
|
||||
$(GO) build -o $(EXE) ./cmd/cli/
|
||||
$(GO) build -o $(EXE) ./$(CLI_DIR)
|
||||
|
||||
bench:
|
||||
$(GO) test ./internal/one/ -bench=. > internal/one/benchmark
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"github.com/onyx-and-iris/aoc2024/day-01/internal/two"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(data)
|
||||
func Solve(buf []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
answerTwo, err := two.Solve(data)
|
||||
answerTwo, err := two.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-02
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkMain-12 1000000000 0.001121 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0009054 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0009948 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0008774 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0009065 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0008702 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0008654 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0008806 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0009256 ns/op
|
||||
BenchmarkMain-12 1000000000 0.0009088 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-02 0.085s
|
||||
BenchmarkSolve-12 1000000000 0.0009264 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008785 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009170 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009721 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008991 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009518 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009118 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009975 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008687 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008922 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-02 0.088s
|
||||
|
||||
@@ -2,5 +2,5 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-02/internal/one
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkMain-12 1000000000 0.0003352 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-02/internal/one 0.009s
|
||||
BenchmarkSolve-12 1000000000 0.0003398 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-02/internal/one 0.010s
|
||||
|
||||
@@ -4,14 +4,12 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-02/internal/util"
|
||||
)
|
||||
|
||||
type comparator func([]int, int) bool
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
sum, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -21,13 +19,23 @@ func Solve(data []byte) (int, error) {
|
||||
}
|
||||
|
||||
func parseLines(r io.Reader) (int, error) {
|
||||
var (
|
||||
cmpIncrease = func(nums []int, i int) bool {
|
||||
return nums[i-1] >= nums[i]
|
||||
}
|
||||
|
||||
cmpDecrease = func(nums []int, i int) bool {
|
||||
return nums[i-1] <= nums[i]
|
||||
}
|
||||
)
|
||||
|
||||
var sum int
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
nums := util.IntsFromString(scanner.Text())
|
||||
nums := intsFromString(scanner.Text())
|
||||
|
||||
if check(nums, util.CmpIncrease) || check(nums, util.CmpDecrease) {
|
||||
if check(nums, cmpIncrease) || check(nums, cmpDecrease) {
|
||||
sum++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
22
day-02/internal/one/util.go
Normal file
22
day-02/internal/one/util.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func intsFromString(s string) []int {
|
||||
nums := []int{}
|
||||
for _, r := range strings.Fields(s) {
|
||||
nums = append(nums, mustConv(r))
|
||||
}
|
||||
return nums
|
||||
}
|
||||
@@ -2,5 +2,5 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-02/internal/two
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkMain-12 1000000000 0.0005847 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0007413 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-02/internal/two 0.011s
|
||||
|
||||
@@ -4,15 +4,13 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-02/internal/util"
|
||||
)
|
||||
|
||||
type comparator func([]int, int) bool
|
||||
type dampener func([]int, comparator, int) bool
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
sum, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -22,13 +20,23 @@ func Solve(data []byte) (int, error) {
|
||||
}
|
||||
|
||||
func parseLines(r io.Reader) (int, error) {
|
||||
var (
|
||||
cmpIncrease = func(nums []int, i int) bool {
|
||||
return nums[i-1] >= nums[i]
|
||||
}
|
||||
|
||||
cmpDecrease = func(nums []int, i int) bool {
|
||||
return nums[i-1] <= nums[i]
|
||||
}
|
||||
)
|
||||
|
||||
var sum int
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
nums := util.IntsFromString(scanner.Text())
|
||||
nums := intsFromString(scanner.Text())
|
||||
|
||||
if check(withDampener, nums, util.CmpIncrease) || check(withDampener, nums, util.CmpDecrease) {
|
||||
if check(withDampener, nums, cmpIncrease) || check(withDampener, nums, cmpDecrease) {
|
||||
sum++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
22
day-02/internal/two/util.go
Normal file
22
day-02/internal/two/util.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func intsFromString(s string) []int {
|
||||
nums := []int{}
|
||||
for _, r := range strings.Fields(s) {
|
||||
nums = append(nums, mustConv(r))
|
||||
}
|
||||
return nums
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func MustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func IntsFromString(s string) []int {
|
||||
nums := []int{}
|
||||
for _, r := range strings.Fields(s) {
|
||||
nums = append(nums, MustConv(r))
|
||||
}
|
||||
return nums
|
||||
}
|
||||
|
||||
var CmpIncrease = func(nums []int, i int) bool {
|
||||
return nums[i-1] >= nums[i]
|
||||
}
|
||||
|
||||
var CmpDecrease = func(nums []int, i int) bool {
|
||||
return nums[i-1] <= nums[i]
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
program = day-02
|
||||
|
||||
GO = go
|
||||
SRC_DIR := src
|
||||
CLI_DIR := cmd/cli
|
||||
BIN_DIR := bin
|
||||
|
||||
EXE := $(BIN_DIR)/$(program)
|
||||
@@ -16,7 +16,7 @@ vet: fmt
|
||||
$(GO) vet ./...
|
||||
|
||||
build: vet | $(BIN_DIR)
|
||||
$(GO) build -o $(EXE) ./$(SRC_DIR)
|
||||
$(GO) build -o $(EXE) ./$(CLI_DIR)
|
||||
|
||||
bench:
|
||||
$(GO) test ./internal/one/ -bench=. > internal/one/benchmark
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"github.com/onyx-and-iris/aoc2024/day-02/internal/two"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(data)
|
||||
func Solve(buf []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
answerTwo, err := two.Solve(data)
|
||||
answerTwo, err := two.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-03
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkMain-12 1000000000 0.001213 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001343 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001210 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001314 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001288 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001646 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001211 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001174 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001220 ns/op
|
||||
BenchmarkMain-12 1000000000 0.001169 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-03 0.104s
|
||||
BenchmarkSolve-12 1000000000 0.0008731 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009794 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008804 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008202 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008964 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008750 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008836 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009397 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008660 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009075 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-03 0.084s
|
||||
|
||||
@@ -20,7 +20,7 @@ var files embed.FS
|
||||
|
||||
func main() {
|
||||
filename := flag.String("f", "input.txt", "input file")
|
||||
loglevel := flag.Int("l", int(log.InfoLevel), "log level (shorthand)")
|
||||
loglevel := flag.Int("l", int(log.InfoLevel), "log level")
|
||||
flag.Parse()
|
||||
|
||||
if slices.Contains(log.AllLevels, log.Level(*loglevel)) {
|
||||
|
||||
@@ -2,5 +2,5 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-03/internal/one
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkMain-12 1000000000 0.0006976 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-03/internal/one 0.010s
|
||||
BenchmarkSolve-12 1000000000 0.0003246 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-03/internal/one 0.008s
|
||||
|
||||
@@ -5,14 +5,12 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"regexp"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-03/internal/util"
|
||||
)
|
||||
|
||||
var reMul = regexp.MustCompile(`mul\(([0-9]{1,3}),([0-9]{1,3})\)`)
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
sum, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -28,7 +26,7 @@ func parseLines(r io.Reader) (int, error) {
|
||||
for scanner.Scan() {
|
||||
matches := reMul.FindAllStringSubmatch(scanner.Text(), -1)
|
||||
for _, m := range matches {
|
||||
sum += util.MustConv(m[1]) * util.MustConv(m[2])
|
||||
sum += mustConv(m[1]) * mustConv(m[2])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package util
|
||||
package one
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
import "strconv"
|
||||
|
||||
func MustConv(s string) int {
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -2,5 +2,5 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-03/internal/two
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkMain-12 1000000000 0.0006480 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0005802 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-03/internal/two 0.010s
|
||||
|
||||
@@ -6,15 +6,13 @@ import (
|
||||
"io"
|
||||
"regexp"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-03/internal/util"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var reMulOrDoOrDont = regexp.MustCompile(`mul\(([0-9]{1,3}),([0-9]{1,3})\)|do\(\)|don't\(\)`)
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
sum, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -43,7 +41,7 @@ func parseLines(r io.Reader) (int, error) {
|
||||
if do {
|
||||
if m[1] != "" && m[2] != "" {
|
||||
log.Debugf("%s * %s\n", m[1], m[2])
|
||||
sum += util.MustConv(m[1]) * util.MustConv(m[2])
|
||||
sum += mustConv(m[1]) * mustConv(m[2])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
11
day-03/internal/two/util.go
Normal file
11
day-03/internal/two/util.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package two
|
||||
|
||||
import "strconv"
|
||||
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
program = day-03
|
||||
|
||||
GO = go
|
||||
SRC_DIR := src
|
||||
CLI_DIR := cmd/cli
|
||||
BIN_DIR := bin
|
||||
|
||||
EXE := $(BIN_DIR)/$(program)
|
||||
@@ -16,7 +16,7 @@ vet: fmt
|
||||
$(GO) vet ./...
|
||||
|
||||
build: vet | $(BIN_DIR)
|
||||
$(GO) build -o $(EXE) ./$(SRC_DIR)
|
||||
$(GO) build -o $(EXE) ./$(CLI_DIR)
|
||||
|
||||
bench:
|
||||
$(GO) test ./internal/one/ -bench=. > internal/one/benchmark
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"github.com/onyx-and-iris/aoc2024/day-03/internal/two"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(data)
|
||||
func Solve(buf []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
answerTwo, err := two.Solve(data)
|
||||
answerTwo, err := two.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkMain(b *testing.B) {
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-04
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.007163 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007083 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007305 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006918 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006992 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007054 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007061 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007061 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007928 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007870 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-04 0.470s
|
||||
BenchmarkSolve-12 1000000000 0.006587 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007100 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.007078 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006522 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006816 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006618 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006602 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006679 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006641 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006810 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-04 0.447s
|
||||
|
||||
@@ -2,5 +2,5 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-04/internal/one
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.001288 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-04/internal/one 0.013s
|
||||
BenchmarkSolve-12 1000000000 0.0008120 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-04/internal/one 0.010s
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package one
|
||||
|
||||
type direction int
|
||||
|
||||
const (
|
||||
N = iota
|
||||
N direction = iota
|
||||
NE
|
||||
E
|
||||
SE
|
||||
|
||||
17
day-04/internal/one/graph.go
Normal file
17
day-04/internal/one/graph.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package one
|
||||
|
||||
type graph struct {
|
||||
data []string
|
||||
}
|
||||
|
||||
func newGraph() *graph {
|
||||
return &graph{}
|
||||
}
|
||||
|
||||
func (g *graph) valueAt(p point) rune {
|
||||
return rune(g.data[p.y][p.x])
|
||||
}
|
||||
|
||||
func (g *graph) isOutOfBounds(p point) bool {
|
||||
return p.x < 0 || p.y < 0 || p.y >= len(g.data) || p.x >= len(g.data[p.y])
|
||||
}
|
||||
@@ -1,58 +1,14 @@
|
||||
package one
|
||||
|
||||
type neighbour struct {
|
||||
x int
|
||||
y int
|
||||
direction int
|
||||
}
|
||||
|
||||
func newNeighbour(direction, x, y int) neighbour {
|
||||
switch direction {
|
||||
case N:
|
||||
return neighbour{x, y + 1, direction}
|
||||
case NE:
|
||||
return neighbour{x + 1, y + 1, direction}
|
||||
case E:
|
||||
return neighbour{x + 1, y, direction}
|
||||
case SE:
|
||||
return neighbour{x + 1, y - 1, direction}
|
||||
case S:
|
||||
return neighbour{x, y - 1, direction}
|
||||
case SW:
|
||||
return neighbour{x - 1, y - 1, direction}
|
||||
case W:
|
||||
return neighbour{x - 1, y, direction}
|
||||
case NW:
|
||||
return neighbour{x - 1, y + 1, direction}
|
||||
default:
|
||||
return neighbour{}
|
||||
func neighbours(p point) [8]point {
|
||||
return [8]point{
|
||||
{p.x, p.y - 1, N},
|
||||
{p.x + 1, p.y - 1, NE},
|
||||
{p.x + 1, p.y, E},
|
||||
{p.x + 1, p.y + 1, SE},
|
||||
{p.x, p.y + 1, S},
|
||||
{p.x - 1, p.y + 1, SW},
|
||||
{p.x - 1, p.y, W},
|
||||
{p.x - 1, p.y - 1, NW},
|
||||
}
|
||||
}
|
||||
|
||||
type neighbours struct {
|
||||
N neighbour
|
||||
NE neighbour
|
||||
E neighbour
|
||||
SE neighbour
|
||||
S neighbour
|
||||
SW neighbour
|
||||
W neighbour
|
||||
NW neighbour
|
||||
}
|
||||
|
||||
func newNeighbours(x, y int) neighbours {
|
||||
return neighbours{
|
||||
newNeighbour(N, x, y),
|
||||
newNeighbour(NE, x, y),
|
||||
newNeighbour(E, x, y),
|
||||
newNeighbour(SE, x, y),
|
||||
newNeighbour(S, x, y),
|
||||
newNeighbour(SW, x, y),
|
||||
newNeighbour(W, x, y),
|
||||
newNeighbour(NW, x, y),
|
||||
}
|
||||
}
|
||||
|
||||
func (n neighbours) all() [8]neighbour {
|
||||
return [8]neighbour{n.N, n.NE, n.E, n.SE, n.S, n.SW, n.W, n.NW}
|
||||
}
|
||||
|
||||
10
day-04/internal/one/point.go
Normal file
10
day-04/internal/one/point.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package one
|
||||
|
||||
type point struct {
|
||||
x, y int
|
||||
direction direction
|
||||
}
|
||||
|
||||
func newPoint(x, y int) point {
|
||||
return point{x: x, y: y}
|
||||
}
|
||||
@@ -3,30 +3,23 @@ package one
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-04/internal/util"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
lines, err := util.ReadLines(r)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
graph, err := readLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var sum int
|
||||
|
||||
for i := 0; i < len(lines); i++ {
|
||||
for j := 0; j < len(lines[i]); j++ {
|
||||
neighbours := newNeighbours(j, i)
|
||||
for _, n := range neighbours.all() {
|
||||
if n.x < 0 || n.y < 0 || n.y >= len(lines) || n.x >= len(lines[i]) {
|
||||
continue
|
||||
}
|
||||
|
||||
if lines[i][j] == 'X' {
|
||||
if checkNeighbours(n, "MAS", lines) {
|
||||
for y := range graph.data {
|
||||
for x := range graph.data[y] {
|
||||
current := newPoint(x, y)
|
||||
if graph.valueAt(current) == 'X' {
|
||||
for _, n := range neighbours(current) {
|
||||
if checkNeighbours(n, "MAS", graph) {
|
||||
sum++
|
||||
}
|
||||
}
|
||||
@@ -37,19 +30,19 @@ func Solve(data []byte) (int, error) {
|
||||
return sum, nil
|
||||
}
|
||||
|
||||
func checkNeighbours(n neighbour, word string, lines []string) bool {
|
||||
func checkNeighbours(n point, word string, g *graph) bool {
|
||||
if len(word) == 0 {
|
||||
log.Debug("we found a full XMAS")
|
||||
return true
|
||||
}
|
||||
|
||||
if n.x < 0 || n.y < 0 || n.y >= len(lines) || n.x >= len(lines[n.y]) {
|
||||
if g.isOutOfBounds(n) {
|
||||
return false
|
||||
}
|
||||
|
||||
if lines[n.y][n.x] != word[0] {
|
||||
if g.valueAt(n) != rune(word[0]) {
|
||||
return false
|
||||
}
|
||||
|
||||
return checkNeighbours(newNeighbour(n.direction, n.x, n.y), word[1:], lines)
|
||||
return checkNeighbours(neighbours(n)[n.direction], word[1:], g)
|
||||
}
|
||||
|
||||
21
day-04/internal/one/util.go
Normal file
21
day-04/internal/one/util.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
)
|
||||
|
||||
func readLines(r io.Reader) (*graph, error) {
|
||||
graph := newGraph()
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
graph.data = append(graph.data, scanner.Text())
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return graph, nil
|
||||
}
|
||||
@@ -2,5 +2,5 @@ goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-04/internal/two
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.005979 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.006037 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-04/internal/two 0.042s
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package two
|
||||
|
||||
type direction int
|
||||
|
||||
const (
|
||||
NW = iota
|
||||
NW direction = iota
|
||||
NE
|
||||
SE
|
||||
SW
|
||||
|
||||
17
day-04/internal/two/graph.go
Normal file
17
day-04/internal/two/graph.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package two
|
||||
|
||||
type graph struct {
|
||||
data []string
|
||||
}
|
||||
|
||||
func newGraph() *graph {
|
||||
return &graph{}
|
||||
}
|
||||
|
||||
func (g *graph) valueAt(p point) rune {
|
||||
return rune(g.data[p.y][p.x])
|
||||
}
|
||||
|
||||
func (g *graph) isOutOfBounds(p point) bool {
|
||||
return p.x < 0 || p.y < 0 || p.y >= len(g.data) || p.x >= len(g.data[p.y])
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func (m *matrix) rotate() *matrix {
|
||||
return &temp
|
||||
}
|
||||
|
||||
func (m *matrix) validate() bool {
|
||||
func (m *matrix) isValid() bool {
|
||||
golden := &matrix{
|
||||
{'M', -1, 'M'},
|
||||
{-1, 'A', -1},
|
||||
|
||||
@@ -1,50 +1,10 @@
|
||||
package two
|
||||
|
||||
type neighbour struct {
|
||||
x int
|
||||
y int
|
||||
direction int
|
||||
}
|
||||
|
||||
func newNeighbour(direction, x, y int) neighbour {
|
||||
switch direction {
|
||||
case NW:
|
||||
return neighbour{x - 1, y + 1, direction}
|
||||
case NE:
|
||||
return neighbour{x + 1, y + 1, direction}
|
||||
case SE:
|
||||
return neighbour{x + 1, y - 1, direction}
|
||||
case SW:
|
||||
return neighbour{x - 1, y - 1, direction}
|
||||
default:
|
||||
return neighbour{}
|
||||
func neighbours(p point) [4]point {
|
||||
return [4]point{
|
||||
{p.x - 1, p.y - 1, NW},
|
||||
{p.x + 1, p.y - 1, NE},
|
||||
{p.x + 1, p.y + 1, SE},
|
||||
{p.x - 1, p.y + 1, SW},
|
||||
}
|
||||
}
|
||||
|
||||
func (n neighbour) outOfBounds(lines []string) bool {
|
||||
return n.x < 0 || n.y < 0 || n.y >= len(lines) || n.x >= len(lines[0])
|
||||
}
|
||||
|
||||
func (n neighbour) value(lines []string) rune {
|
||||
return rune(lines[n.y][n.x])
|
||||
}
|
||||
|
||||
type neighbours struct {
|
||||
NW neighbour
|
||||
NE neighbour
|
||||
SE neighbour
|
||||
SW neighbour
|
||||
}
|
||||
|
||||
func newNeighbours(x, y int) neighbours {
|
||||
return neighbours{
|
||||
newNeighbour(NW, x, y),
|
||||
newNeighbour(NE, x, y),
|
||||
newNeighbour(SE, x, y),
|
||||
newNeighbour(SW, x, y),
|
||||
}
|
||||
}
|
||||
|
||||
func (n neighbours) all() [4]neighbour {
|
||||
return [4]neighbour{n.NW, n.NE, n.SE, n.SW}
|
||||
}
|
||||
|
||||
10
day-04/internal/two/point.go
Normal file
10
day-04/internal/two/point.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package two
|
||||
|
||||
type point struct {
|
||||
x, y int
|
||||
direction direction
|
||||
}
|
||||
|
||||
func newPoint(x, y int) point {
|
||||
return point{x: x, y: y}
|
||||
}
|
||||
@@ -3,29 +3,27 @@ package two
|
||||
import (
|
||||
"bytes"
|
||||
"slices"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-04/internal/util"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, error) {
|
||||
r := bytes.NewReader(data)
|
||||
lines, err := util.ReadLines(r)
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
graph, err := readLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var sum int
|
||||
|
||||
for i := 0; i < len(lines); i++ {
|
||||
for j := 0; j < len(lines[i]); j++ {
|
||||
if lines[i][j] == 'A' {
|
||||
neighbours := newNeighbours(j, i)
|
||||
for y := range graph.data {
|
||||
for x := range graph.data[y] {
|
||||
current := newPoint(x, y)
|
||||
if graph.valueAt(current) == 'A' {
|
||||
if func() bool {
|
||||
for _, n := range neighbours.all() {
|
||||
if n.outOfBounds(lines) {
|
||||
for _, n := range neighbours(current) {
|
||||
if graph.isOutOfBounds(n) {
|
||||
return true
|
||||
}
|
||||
if !slices.Contains([]rune{'M', 'S'}, n.value(lines)) {
|
||||
|
||||
if !slices.Contains([]rune{'M', 'S'}, graph.valueAt(n)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -34,15 +32,16 @@ func Solve(data []byte) (int, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
ns := neighbours(current)
|
||||
matrix := newMatrix(
|
||||
rune(lines[i][j]),
|
||||
neighbours.NW.value(lines),
|
||||
neighbours.NE.value(lines),
|
||||
neighbours.SE.value(lines),
|
||||
neighbours.SW.value(lines),
|
||||
graph.valueAt(current),
|
||||
graph.valueAt(ns[NW]),
|
||||
graph.valueAt(ns[NE]),
|
||||
graph.valueAt(ns[SE]),
|
||||
graph.valueAt(ns[SW]),
|
||||
)
|
||||
|
||||
if matrix.validate() {
|
||||
if matrix.isValid() {
|
||||
sum++
|
||||
}
|
||||
}
|
||||
|
||||
21
day-04/internal/two/util.go
Normal file
21
day-04/internal/two/util.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
)
|
||||
|
||||
func readLines(r io.Reader) (*graph, error) {
|
||||
graph := newGraph()
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
graph.data = append(graph.data, scanner.Text())
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return graph, nil
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
)
|
||||
|
||||
func ReadLines(r io.Reader) ([]string, error) {
|
||||
lines := []string{}
|
||||
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
return lines, nil
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
program = day-04
|
||||
|
||||
GO = go
|
||||
SRC_DIR := src
|
||||
CLI_DIR := cmd/cli
|
||||
BIN_DIR := bin
|
||||
|
||||
EXE := $(BIN_DIR)/$(program)
|
||||
@@ -16,7 +16,7 @@ vet: fmt
|
||||
$(GO) vet ./...
|
||||
|
||||
build: vet | $(BIN_DIR)
|
||||
$(GO) build -o $(EXE) ./$(SRC_DIR)
|
||||
$(GO) build -o $(EXE) ./$(CLI_DIR)
|
||||
|
||||
bench:
|
||||
$(GO) test ./internal/one/ -bench=. > internal/one/benchmark
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"github.com/onyx-and-iris/aoc2024/day-04/internal/two"
|
||||
)
|
||||
|
||||
func Solve(data []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(data)
|
||||
func Solve(buf []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
answerTwo, err := two.Solve(data)
|
||||
answerTwo, err := two.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
15
day-05/benchmark
Normal file
15
day-05/benchmark
Normal file
@@ -0,0 +1,15 @@
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-05
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.0008567 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009254 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008466 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0009264 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.001003 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008865 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008920 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008658 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008974 ns/op
|
||||
BenchmarkSolve-12 1000000000 0.0008448 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-05 0.087s
|
||||
41
day-05/cmd/cli/main.go
Normal file
41
day-05/cmd/cli/main.go
Normal file
@@ -0,0 +1,41 @@
|
||||
/********************************************************************************
|
||||
Advent of Code 2024 - day-05
|
||||
********************************************************************************/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
problems "github.com/onyx-and-iris/aoc2024/day-05"
|
||||
)
|
||||
|
||||
//go:embed testdata
|
||||
var files embed.FS
|
||||
|
||||
func main() {
|
||||
filename := flag.String("f", "input.txt", "input file")
|
||||
loglevel := flag.Int("l", int(log.InfoLevel), "log level")
|
||||
flag.Parse()
|
||||
|
||||
if slices.Contains(log.AllLevels, log.Level(*loglevel)) {
|
||||
log.SetLevel(log.Level(*loglevel))
|
||||
}
|
||||
|
||||
data, err := files.ReadFile(fmt.Sprintf("testdata/%s", *filename))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
one, two, err := problems.Solve(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("solution one: %d\nsolution two: %d\n", one, two)
|
||||
}
|
||||
7
day-05/go.mod
Normal file
7
day-05/go.mod
Normal file
@@ -0,0 +1,7 @@
|
||||
module github.com/onyx-and-iris/aoc2024/day-05
|
||||
|
||||
go 1.23.3
|
||||
|
||||
require github.com/sirupsen/logrus v1.9.3
|
||||
|
||||
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
15
day-05/go.sum
Normal file
15
day-05/go.sum
Normal file
@@ -0,0 +1,15 @@
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
6
day-05/internal/one/benchmark
Normal file
6
day-05/internal/one/benchmark
Normal file
@@ -0,0 +1,6 @@
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-05/internal/one
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.0004717 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-05/internal/one 0.009s
|
||||
27
day-05/internal/one/solve.go
Normal file
27
day-05/internal/one/solve.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"slices"
|
||||
)
|
||||
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
updates, orderings, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var sum int
|
||||
|
||||
for _, update := range updates {
|
||||
beforeSort := slices.Clone(update.Pages)
|
||||
update.Sort(orderings)
|
||||
|
||||
if slices.Compare(beforeSort, update.Pages) == 0 {
|
||||
sum += update.Pages[len(update.Pages)/2]
|
||||
}
|
||||
}
|
||||
|
||||
return sum, nil
|
||||
}
|
||||
15
day-05/internal/one/solve_internal_test.go
Normal file
15
day-05/internal/one/solve_internal_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
53
day-05/internal/one/util.go
Normal file
53
day-05/internal/one/util.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-05/internal/update"
|
||||
)
|
||||
|
||||
func parseLines(r io.Reader) ([]update.Update, map[int][]int, error) {
|
||||
var updates []update.Update
|
||||
orderings := make(map[int][]int, 0)
|
||||
|
||||
var inUpdates bool
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if len(line) == 0 {
|
||||
inUpdates = true
|
||||
continue
|
||||
}
|
||||
|
||||
if inUpdates {
|
||||
var update update.Update
|
||||
for _, n := range strings.Split(line, ",") {
|
||||
update.Pages = append(update.Pages, mustConv(n))
|
||||
}
|
||||
updates = append(updates, update)
|
||||
} else {
|
||||
left, right := func() (int, int) {
|
||||
x := strings.Split(line, "|")
|
||||
return mustConv(x[0]), mustConv(x[1])
|
||||
}()
|
||||
orderings[left] = append(orderings[left], right)
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return updates, orderings, nil
|
||||
}
|
||||
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
6
day-05/internal/two/benchmark
Normal file
6
day-05/internal/two/benchmark
Normal file
@@ -0,0 +1,6 @@
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-05/internal/two
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.0006518 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-05/internal/two 0.013s
|
||||
27
day-05/internal/two/solve.go
Normal file
27
day-05/internal/two/solve.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"slices"
|
||||
)
|
||||
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
updates, orderings, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var sum int
|
||||
|
||||
for _, update := range updates {
|
||||
beforeSort := slices.Clone(update.Pages)
|
||||
update.Sort(orderings)
|
||||
|
||||
if slices.Compare(beforeSort, update.Pages) != 0 {
|
||||
sum += update.Pages[len(update.Pages)/2]
|
||||
}
|
||||
}
|
||||
|
||||
return sum, nil
|
||||
}
|
||||
15
day-05/internal/two/solve_internal_test.go
Normal file
15
day-05/internal/two/solve_internal_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
53
day-05/internal/two/util.go
Normal file
53
day-05/internal/two/util.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/onyx-and-iris/aoc2024/day-05/internal/update"
|
||||
)
|
||||
|
||||
func parseLines(r io.Reader) ([]update.Update, map[int][]int, error) {
|
||||
var updates []update.Update
|
||||
orderings := make(map[int][]int, 0)
|
||||
|
||||
var inUpdates bool
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if len(line) == 0 {
|
||||
inUpdates = true
|
||||
continue
|
||||
}
|
||||
|
||||
if inUpdates {
|
||||
var update update.Update
|
||||
for _, n := range strings.Split(line, ",") {
|
||||
update.Pages = append(update.Pages, mustConv(n))
|
||||
}
|
||||
updates = append(updates, update)
|
||||
} else {
|
||||
left, right := func() (int, int) {
|
||||
x := strings.Split(line, "|")
|
||||
return mustConv(x[0]), mustConv(x[1])
|
||||
}()
|
||||
orderings[left] = append(orderings[left], right)
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return updates, orderings, nil
|
||||
}
|
||||
|
||||
func mustConv(s string) int {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
20
day-05/internal/update/update.go
Normal file
20
day-05/internal/update/update.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package update
|
||||
|
||||
import "slices"
|
||||
|
||||
type Update struct {
|
||||
Pages []int
|
||||
}
|
||||
|
||||
func (u Update) Sort(orderings map[int][]int) {
|
||||
slices.SortFunc(u.Pages, func(p, q int) int {
|
||||
v, ok := orderings[p]
|
||||
if ok {
|
||||
if slices.Contains(v, q) {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
return 1
|
||||
})
|
||||
}
|
||||
30
day-05/makefile
Normal file
30
day-05/makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
program = day-05
|
||||
|
||||
GO = go
|
||||
CLI_DIR := cmd/cli
|
||||
BIN_DIR := bin
|
||||
|
||||
EXE := $(BIN_DIR)/$(program)
|
||||
|
||||
.DEFAULT_GOAL := build
|
||||
|
||||
.PHONY: fmt vet build bench clean
|
||||
fmt:
|
||||
$(GO) fmt ./...
|
||||
|
||||
vet: fmt
|
||||
$(GO) vet ./...
|
||||
|
||||
build: vet | $(BIN_DIR)
|
||||
$(GO) build -o $(EXE) ./$(CLI_DIR)
|
||||
|
||||
bench:
|
||||
$(GO) test ./internal/one/ -bench=. > internal/one/benchmark
|
||||
$(GO) test ./internal/two/ -bench=. > internal/two/benchmark
|
||||
$(GO) test . -count=10 -bench=. > benchmark
|
||||
|
||||
$(BIN_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
clean:
|
||||
@rm -rv $(BIN_DIR)
|
||||
20
day-05/solve.go
Normal file
20
day-05/solve.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package dayfive
|
||||
|
||||
import (
|
||||
"github.com/onyx-and-iris/aoc2024/day-05/internal/one"
|
||||
"github.com/onyx-and-iris/aoc2024/day-05/internal/two"
|
||||
)
|
||||
|
||||
func Solve(buf []byte) (int, int, error) {
|
||||
answerOne, err := one.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
answerTwo, err := two.Solve(buf)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return answerOne, answerTwo, nil
|
||||
}
|
||||
15
day-05/solve_internal_test.go
Normal file
15
day-05/solve_internal_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package dayfive
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
15
day-06/benchmark
Normal file
15
day-06/benchmark
Normal file
@@ -0,0 +1,15 @@
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-06
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1 1938623306 ns/op
|
||||
BenchmarkSolve-12 1 1699617582 ns/op
|
||||
BenchmarkSolve-12 1 1798247781 ns/op
|
||||
BenchmarkSolve-12 1 1764834081 ns/op
|
||||
BenchmarkSolve-12 1 1683804882 ns/op
|
||||
BenchmarkSolve-12 1 1678726099 ns/op
|
||||
BenchmarkSolve-12 1 1746567303 ns/op
|
||||
BenchmarkSolve-12 1 1657025304 ns/op
|
||||
BenchmarkSolve-12 1 1682179303 ns/op
|
||||
BenchmarkSolve-12 1 1782072103 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-06 17.460s
|
||||
41
day-06/cmd/cli/main.go
Normal file
41
day-06/cmd/cli/main.go
Normal file
@@ -0,0 +1,41 @@
|
||||
/********************************************************************************
|
||||
Advent of Code 2024 - day-06
|
||||
********************************************************************************/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
problems "github.com/onyx-and-iris/aoc2024/day-06"
|
||||
)
|
||||
|
||||
//go:embed testdata
|
||||
var files embed.FS
|
||||
|
||||
func main() {
|
||||
filename := flag.String("f", "input.txt", "input file")
|
||||
loglevel := flag.Int("l", int(log.InfoLevel), "log level")
|
||||
flag.Parse()
|
||||
|
||||
if slices.Contains(log.AllLevels, log.Level(*loglevel)) {
|
||||
log.SetLevel(log.Level(*loglevel))
|
||||
}
|
||||
|
||||
data, err := files.ReadFile(fmt.Sprintf("testdata/%s", *filename))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
one, two, err := problems.Solve(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("solution one: %d\nsolution two: %d\n", one, two)
|
||||
}
|
||||
7
day-06/go.mod
Normal file
7
day-06/go.mod
Normal file
@@ -0,0 +1,7 @@
|
||||
module github.com/onyx-and-iris/aoc2024/day-06
|
||||
|
||||
go 1.23.3
|
||||
|
||||
require github.com/sirupsen/logrus v1.9.3
|
||||
|
||||
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
15
day-06/go.sum
Normal file
15
day-06/go.sum
Normal file
@@ -0,0 +1,15 @@
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
6
day-06/internal/one/benchmark
Normal file
6
day-06/internal/one/benchmark
Normal file
@@ -0,0 +1,6 @@
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-06/internal/one
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.01028 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-06/internal/one 0.057s
|
||||
8
day-06/internal/one/direction.go
Normal file
8
day-06/internal/one/direction.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package one
|
||||
|
||||
const (
|
||||
N = iota
|
||||
E
|
||||
S
|
||||
W
|
||||
)
|
||||
28
day-06/internal/one/graph.go
Normal file
28
day-06/internal/one/graph.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type graph struct {
|
||||
startPoint point
|
||||
data []string
|
||||
}
|
||||
|
||||
func newGraph() *graph {
|
||||
return &graph{}
|
||||
}
|
||||
|
||||
func (g *graph) String() string {
|
||||
return strings.Join(g.data, "\n")
|
||||
}
|
||||
|
||||
func (g *graph) debug(visited map[coords]struct{}) string {
|
||||
for loc := range visited {
|
||||
if !(rune(g.data[loc.Y][loc.X]) == 'O') {
|
||||
g.data[loc.Y] = replaceAtIndex(g.data[loc.Y], '+', loc.X)
|
||||
}
|
||||
}
|
||||
|
||||
return g.String()
|
||||
}
|
||||
51
day-06/internal/one/point.go
Normal file
51
day-06/internal/one/point.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package one
|
||||
|
||||
import "fmt"
|
||||
|
||||
type coords struct {
|
||||
X int
|
||||
Y int
|
||||
}
|
||||
|
||||
type point struct {
|
||||
coords
|
||||
direction int
|
||||
}
|
||||
|
||||
func (p *point) String() string {
|
||||
return fmt.Sprintf("X: %d Y:%d Direction: %s", p.X, p.Y, []string{"N", "E", "S", "W"}[p.direction])
|
||||
}
|
||||
|
||||
func (p *point) recalibrate() {
|
||||
switch p.direction {
|
||||
case N:
|
||||
p.Y++
|
||||
case E:
|
||||
p.X--
|
||||
case S:
|
||||
p.Y--
|
||||
case W:
|
||||
p.X++
|
||||
}
|
||||
|
||||
if p.direction == W {
|
||||
p.direction = 0
|
||||
} else {
|
||||
p.direction++
|
||||
}
|
||||
}
|
||||
|
||||
func nextPoint(current point) point {
|
||||
switch current.direction {
|
||||
case N:
|
||||
return point{coords{current.X, current.Y - 1}, current.direction}
|
||||
case E:
|
||||
return point{coords{current.X + 1, current.Y}, current.direction}
|
||||
case S:
|
||||
return point{coords{current.X, current.Y + 1}, current.direction}
|
||||
case W:
|
||||
return point{coords{current.X - 1, current.Y}, current.direction}
|
||||
default:
|
||||
return point{}
|
||||
}
|
||||
}
|
||||
51
day-06/internal/one/solve.go
Normal file
51
day-06/internal/one/solve.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var Visited = make(map[coords]struct{})
|
||||
|
||||
func Solve(buf []byte) (int, error) {
|
||||
r := bytes.NewReader(buf)
|
||||
graph, err := parseLines(r)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
log.Debug(graph.startPoint.String())
|
||||
|
||||
var count int
|
||||
count = nextStep(graph.startPoint, Visited, count, graph)
|
||||
log.Debugf("path walked: \n%s\n", graph.debug(Visited))
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func nextStep(point point, visited map[coords]struct{}, count int, g *graph) int {
|
||||
_, ok := visited[point.coords]
|
||||
if !ok {
|
||||
visited[point.coords] = struct{}{}
|
||||
count++
|
||||
}
|
||||
|
||||
log.Debugf("count: %d\n", count)
|
||||
|
||||
if point.X == 0 && point.direction == W ||
|
||||
point.Y == 0 && point.direction == N ||
|
||||
point.Y == len(g.data)-1 && point.direction == S ||
|
||||
point.X == len(g.data[point.Y])-1 && point.direction == E {
|
||||
return count
|
||||
}
|
||||
|
||||
next := nextPoint(point)
|
||||
log.Debug(next.String())
|
||||
log.Debug(string(g.data[next.Y][next.X]))
|
||||
if g.data[next.Y][next.X] == '#' {
|
||||
next.recalibrate()
|
||||
log.Debugf("switched direction to %d", next.direction)
|
||||
}
|
||||
|
||||
return nextStep(next, visited, count, g)
|
||||
}
|
||||
15
day-06/internal/one/solve_internal_test.go
Normal file
15
day-06/internal/one/solve_internal_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/input.txt
|
||||
var data []byte
|
||||
|
||||
func BenchmarkSolve(b *testing.B) {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
Solve(data)
|
||||
}
|
||||
35
day-06/internal/one/util.go
Normal file
35
day-06/internal/one/util.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package one
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func parseLines(r io.Reader) (*graph, error) {
|
||||
graph := newGraph()
|
||||
|
||||
count := 0
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
indx := strings.Index(line, "^")
|
||||
if indx != -1 {
|
||||
graph.startPoint = point{coords{indx, count}, N}
|
||||
}
|
||||
graph.data = append(graph.data, scanner.Text())
|
||||
count++
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return graph, nil
|
||||
}
|
||||
|
||||
func replaceAtIndex(s string, r rune, i int) string {
|
||||
out := []rune(s)
|
||||
out[i] = r
|
||||
return string(out)
|
||||
}
|
||||
6
day-06/internal/two/benchmark
Normal file
6
day-06/internal/two/benchmark
Normal file
@@ -0,0 +1,6 @@
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/onyx-and-iris/aoc2024/day-06/internal/two
|
||||
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||
BenchmarkSolve-12 1000000000 0.0000674 ns/op
|
||||
ok github.com/onyx-and-iris/aoc2024/day-06/internal/two 0.007s
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user