Files
advent-of-code-2025/cmd/10/main.go
T

38 lines
743 B
Go
Raw Normal View History

2025-12-19 07:42:00 -06:00
package main
import (
2025-12-20 22:28:28 -06:00
"fmt"
2025-12-20 13:44:07 -06:00
"github.com/StevanFreeborn/advent-of-code-2025/cmd/10/machine"
2025-12-19 07:42:00 -06:00
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
)
func SolvePartOne(filePath string) int {
total := 0
for line := range file.ReadLines(filePath) {
2025-12-20 13:44:07 -06:00
machine := machine.From(line)
buttonsPressed := machine.ConfigureLights()
2025-12-19 07:42:00 -06:00
total += buttonsPressed
}
return total
}
2025-12-20 13:53:21 -06:00
func SolvePartTwo(filePath string) int {
total := 0
2025-12-20 22:28:28 -06:00
linesRead := 0
2025-12-20 13:53:21 -06:00
for line := range file.ReadLines(filePath) {
2025-12-20 22:28:28 -06:00
linesRead++
2025-12-20 13:53:21 -06:00
machine := machine.From(line)
buttonsPressed := machine.ConfigureJoltages()
2025-12-20 22:28:28 -06:00
if buttonsPressed == 0 {
fmt.Printf("No solution found for line %d: %s\n", linesRead, line)
}
2025-12-20 13:53:21 -06:00
total += buttonsPressed
}
return total
}