Compare commits

..

3 Commits

Author SHA1 Message Date
ea037debed fix: silence golangci-lint 2025-12-04 17:35:49 +01:00
a0a0c43690 feat: simplified input parsing by appending all lines directly 2025-12-04 17:32:36 +01:00
bce49d51f7 feat: applied De Morgan simplification 2025-12-04 17:32:18 +01:00
3 changed files with 5 additions and 8 deletions

View File

@@ -45,11 +45,11 @@ func TestPartTwo(t *testing.T) {
PartTwo(input) PartTwo(input)
w.Close() _ = w.Close()
os.Stdout = oldStdout os.Stdout = oldStdout
var buffer bytes.Buffer var buffer bytes.Buffer
buffer.ReadFrom(r) _, _ = buffer.ReadFrom(r)
got := strings.TrimSpace(buffer.String()) got := strings.TrimSpace(buffer.String())
if got != expected { if got != expected {

View File

@@ -91,7 +91,7 @@ func PartTwo(data []string) int {
return false return false
} }
for _, c := range value[1:] { for _, c := range value[1:] {
if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) { if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
return false return false
} }
} }

View File

@@ -14,11 +14,8 @@ func init() {
func ParseInput(filepath string) []string { func ParseInput(filepath string) []string {
content, _ := os.ReadFile(filepath) content, _ := os.ReadFile(filepath)
lines := strings.Split(string(content), "\n") lines := strings.Split(string(content), "\n")
var data []string data := make([]string, 0, len(lines))
for _, line := range lines { return append(data, lines...)
data = append(data, line)
}
return data
} }
func PartOne(data []string) int { func PartOne(data []string) int {