feat: solve part one

This commit is contained in:
2025-12-23 06:22:31 +01:00
parent b0bb02f695
commit 754eba4331

View File

@@ -0,0 +1,40 @@
package dayfour
import (
"advent-of-code/internal/registry"
"os"
"strings"
)
func init() {
registry.Register("2017D4", ParseInput, PartOne, PartTwo)
}
func ParseInput(filepath string) []string {
content, _ := os.ReadFile(filepath)
return strings.Split(string(content), "\n")
}
func PartOne(data []string) int {
validCount := 0
for _, passphrase := range data {
words := strings.Fields(passphrase)
seen := make(map[string]bool, len(words))
hasDuplicate := false
for _, word := range words {
if seen[word] {
hasDuplicate = true
break
}
seen[word] = true
}
if !hasDuplicate {
validCount++
}
}
return validCount
}
func PartTwo(data []string) int {
return 0
}