Merge pull request #15 from StevanFreeborn/stevanfreeborn/feat/solve-day-six-part-two

feat: i came, i saw, and i conquered
This commit is contained in:
Stevan Freeborn
2025-12-12 06:55:12 -06:00
committed by GitHub
3 changed files with 56 additions and 1 deletions
+1 -1
View File
@@ -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. | | 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. | | 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. | | 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/) | | | 07 | [Problem](https://adventofcode.com/2025/day/7) | [Solution](./cmd/07/) | |
| 08 | [Problem](https://adventofcode.com/2025/day/8) | [Solution](./cmd/08/) | | | 08 | [Problem](https://adventofcode.com/2025/day/8) | [Solution](./cmd/08/) | |
| 09 | [Problem](https://adventofcode.com/2025/day/9) | [Solution](./cmd/09/) | | | 09 | [Problem](https://adventofcode.com/2025/day/9) | [Solution](./cmd/09/) | |
+35
View File
@@ -33,3 +33,38 @@ func SolvePartOne(filePath string) int {
return total 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
}
+20
View File
@@ -25,3 +25,23 @@ func TestSolvePartOneWithInput(t *testing.T) {
t.Errorf("got %d but wanted %d", result, expected) 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)
}
}