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

45 lines
798 B
Go
Raw Normal View History

2025-12-03 07:25:24 -06:00
package main
import (
"strings"
"github.com/StevanFreeborn/advent-of-code-2025/cmd/02/rnge"
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
2025-12-03 07:25:24 -06:00
)
const SeparatorCharacter = ","
func SolvePartOne(filePath string) int64 {
input := file.ReadAllText(filePath)
strRanges := strings.SplitSeq(input, SeparatorCharacter)
2025-12-03 07:25:24 -06:00
total := int64(0)
for r := range strRanges {
rng := rnge.From(r)
2025-12-03 07:25:24 -06:00
2025-12-04 06:33:21 -06:00
for id := range rng.InvalidIdsWithEqualHalves() {
total += id
}
}
return total
}
func SolvePartTwo(filePath string) int64 {
input := file.ReadAllText(filePath)
strRanges := strings.SplitSeq(input, SeparatorCharacter)
total := int64(0)
for r := range strRanges {
rng := rnge.From(r)
for id := range rng.InvalidIdsWithTwoOrMoreSeq() {
2025-12-03 07:25:24 -06:00
total += id
}
}
return total
}