From 6d921bbb639d822a5a72ad15d62ed5c42e4cf1c9 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 12 Dec 2025 06:52:39 -0600 Subject: [PATCH 1/2] feat: i came, i saw, and i conquered --- cmd/06/main.go | 35 +++++++++++++++++++++++++++++++++++ cmd/06/main_test.go | 20 ++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/cmd/06/main.go b/cmd/06/main.go index cece549..1bbdeac 100644 --- a/cmd/06/main.go +++ b/cmd/06/main.go @@ -33,3 +33,38 @@ func SolvePartOne(filePath string) int { return total } + +func SolvePartTwo(filePath string) int { + input := file.ReadAllLines(filePath) + numOfRows := len(input) + operatorRowIndex := numOfRows - 1 + operatorRow := input[operatorRowIndex] + operatorRowLength := len(operatorRow) + + total := 0 + operands := []int{} + + for operatorIndex := operatorRowLength - 1; operatorIndex >= 0; operatorIndex-- { + var operandBuilder strings.Builder + + for row := range numOfRows - 1 { + v := string(input[row][operatorIndex]) + operandBuilder.WriteString(v) + } + + operandString := strings.TrimSpace(operandBuilder.String()) + operand, _ := strconv.Atoi(operandString) + operands = append(operands, operand) + operandBuilder.Reset() + + operator := string(operatorRow[operatorIndex]) + + if operator != " " { + total += problem.From(operator, operands).Solve() + operatorIndex-- + operands = []int{} + } + } + + return total +} diff --git a/cmd/06/main_test.go b/cmd/06/main_test.go index 1a93b56..e6837a5 100644 --- a/cmd/06/main_test.go +++ b/cmd/06/main_test.go @@ -25,3 +25,23 @@ func TestSolvePartOneWithInput(t *testing.T) { t.Errorf("got %d but wanted %d", result, expected) } } + +func TestSolvePartTwoWithExampleInput(t *testing.T) { + expected := 3263827 + + result := solution.SolvePartTwo("EXAMPLE.txt") + + if result != expected { + t.Errorf("got %d but wanted %d", result, expected) + } +} + +func TestSolvePartTwoWithInput(t *testing.T) { + expected := 10442199710797 + + result := solution.SolvePartTwo("INPUT.txt") + + if result != expected { + t.Errorf("got %d but wanted %d", result, expected) + } +} From 8869c58d722ec75695afaffcfc3532fa65654f88 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 12 Dec 2025 06:55:01 -0600 Subject: [PATCH 2/2] chore: update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95b41c3..12fb65c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ go test ./cmd/01 | 03 | [Problem](https://adventofcode.com/2025/day/3) | [Solution](./cmd/03/) | Part 1 intuitively makes you think you only care about highest nums, but then you need to consider placement. I once again tripped over the solution using a stack. However chat morally supported me the whole time. | | 04 | [Problem](https://adventofcode.com/2025/day/4) | [Solution](./cmd/04/) | Part 1 was by far the most straight-forward challenge so far. This was easiest day of AoC this year by far. | | 05 | [Problem](https://adventofcode.com/2025/day/5) | [Solution](./cmd/05/) | Part 1 was fairly straight forward. Merging ranges was trickiest bit. I feel like I'm being led into a trap with how straight forward today was. | -| 06 | [Problem](https://adventofcode.com/2025/day/6) | [Solution](./cmd/06/) | Part 1 I don't think it is the best solution, but it does solve it. | +| 06 | [Problem](https://adventofcode.com/2025/day/6) | [Solution](./cmd/06/) | Part 1 I don't think it is the best solution, but it does solve it. I kicked ass on part 2. 🥳 | | 07 | [Problem](https://adventofcode.com/2025/day/7) | [Solution](./cmd/07/) | | | 08 | [Problem](https://adventofcode.com/2025/day/8) | [Solution](./cmd/08/) | | | 09 | [Problem](https://adventofcode.com/2025/day/9) | [Solution](./cmd/09/) | |