|
@@ -105,16 +105,23 @@ func buildStringsForRule(ruleID int, stringsSoFar []string) []string {
|
|
return newStrings
|
|
return newStrings
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+var notMatched []string
|
|
|
|
+
|
|
func part1(validStrings []string) int {
|
|
func part1(validStrings []string) int {
|
|
valid := 0
|
|
valid := 0
|
|
|
|
|
|
for _, message := range messages {
|
|
for _, message := range messages {
|
|
|
|
+ matched := false
|
|
for _, item := range validStrings {
|
|
for _, item := range validStrings {
|
|
if message == item {
|
|
if message == item {
|
|
valid++
|
|
valid++
|
|
|
|
+ matched = true
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if !matched {
|
|
|
|
+ notMatched = append(notMatched, message)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return valid
|
|
return valid
|
|
@@ -139,4 +146,8 @@ func main() {
|
|
|
|
|
|
validStrings := buildStringsForRule(0, []string{""})
|
|
validStrings := buildStringsForRule(0, []string{""})
|
|
fmt.Println("Part1:", part1(validStrings))
|
|
fmt.Println("Part1:", part1(validStrings))
|
|
|
|
+
|
|
|
|
+ fmt.Println(notMatched)
|
|
|
|
+ fmt.Println("42:", buildStringsForRule(42, []string{""}))
|
|
|
|
+ fmt.Println("31:", buildStringsForRule(31, []string{""}))
|
|
}
|
|
}
|