Merge pull request #26 from StevanFreeborn/stevanfreeborn/feat/day-eleven-part-uno
feat: solve day 111 part 1
This commit is contained in:
@@ -36,5 +36,5 @@ go test ./cmd/01
|
|||||||
| 08 | [Problem](https://adventofcode.com/2025/day/8) | [Solution](./cmd/08/) | Part 1 had me down bad. I was on the right track with my original solution, but ended up doing it in a brute force way then figuring out my mistake with the original. Fuck this guy. Part 2 was so much easier once part 1 was sorted out. |
|
| 08 | [Problem](https://adventofcode.com/2025/day/8) | [Solution](./cmd/08/) | Part 1 had me down bad. I was on the right track with my original solution, but ended up doing it in a brute force way then figuring out my mistake with the original. Fuck this guy. Part 2 was so much easier once part 1 was sorted out. |
|
||||||
| 09 | [Problem](https://adventofcode.com/2025/day/9) | [Solution](./cmd/09/) | Part 1 was such a nice break from the madness of day 8. Basically I need to go build some video games. |
|
| 09 | [Problem](https://adventofcode.com/2025/day/9) | [Solution](./cmd/09/) | Part 1 was such a nice break from the madness of day 8. Basically I need to go build some video games. |
|
||||||
| 10 | [Problem](https://adventofcode.com/2025/day/10) | [Solution](./cmd/10/) | Part 1 took me way to look cause I couldn't figure out how to generate all button press combinations. |
|
| 10 | [Problem](https://adventofcode.com/2025/day/10) | [Solution](./cmd/10/) | Part 1 took me way to look cause I couldn't figure out how to generate all button press combinations. |
|
||||||
| 11 | [Problem](https://adventofcode.com/2025/day/11) | [Solution](./cmd/11/) | |
|
| 11 | [Problem](https://adventofcode.com/2025/day/11) | [Solution](./cmd/11/) | DFS to the rescue again. |
|
||||||
| 12 | [Problem](https://adventofcode.com/2025/day/12) | [Solution](./cmd/12/) | |
|
| 12 | [Problem](https://adventofcode.com/2025/day/12) | [Solution](./cmd/12/) | |
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
|
||||||
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/stack"
|
||||||
|
)
|
||||||
|
|
||||||
|
const START_NODE = "you"
|
||||||
|
const END_NODE = "out"
|
||||||
|
|
||||||
|
func SolvePartOne(filePath string) int {
|
||||||
|
adjacencyList := map[string][]string{}
|
||||||
|
|
||||||
|
for line := range file.ReadLines(filePath) {
|
||||||
|
parts := strings.Split(line, ": ")
|
||||||
|
from := parts[0]
|
||||||
|
toList := strings.Split(parts[1], " ")
|
||||||
|
adjacencyList[from] = toList
|
||||||
|
}
|
||||||
|
|
||||||
|
stack := stack.New[string]()
|
||||||
|
stack.Push(START_NODE)
|
||||||
|
pathCount := 0
|
||||||
|
|
||||||
|
for stack.IsEmpty() == false {
|
||||||
|
current, _ := stack.Pop()
|
||||||
|
|
||||||
|
if current == END_NODE {
|
||||||
|
pathCount++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
neighbors := adjacencyList[current]
|
||||||
|
|
||||||
|
for _, n := range neighbors {
|
||||||
|
stack.Push(n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pathCount
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package main_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
solution "github.com/StevanFreeborn/advent-of-code-2025/cmd/11"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSolvePartOneWithExampleInput(t *testing.T) {
|
||||||
|
expected := 5
|
||||||
|
|
||||||
|
result := solution.SolvePartOne("EXAMPLE.txt")
|
||||||
|
|
||||||
|
if result != expected {
|
||||||
|
t.Errorf("SolvePartOne(EXAMPLE.txt) = %d; want %d", result, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSolvePartOneWithInput(t *testing.T) {
|
||||||
|
expected := 599
|
||||||
|
|
||||||
|
result := solution.SolvePartOne("INPUT.txt")
|
||||||
|
|
||||||
|
if result != expected {
|
||||||
|
t.Errorf("SolvePartOne(INPUT.txt) = %d; want %d", result, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user