Files

45 lines
798 B
Go

package main
import (
"strings"
"github.com/StevanFreeborn/advent-of-code-2025/cmd/02/rnge"
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
)
const SeparatorCharacter = ","
func SolvePartOne(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.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() {
total += id
}
}
return total
}