add comments
add comments to day02 and day03
This commit is contained in:
parent
d67d377bd4
commit
faaff8013f
2 changed files with 5 additions and 1 deletions
|
@ -20,6 +20,7 @@ func main() {
|
|||
}
|
||||
|
||||
func findAndExecuteInstructions(memory string) (res int) {
|
||||
// find all `mul()` and save numbers as MatchGroup 1 + 2
|
||||
re := regexp.MustCompile(`mul\((\d{1,3}),(\d{1,3})\)`)
|
||||
instructions := re.FindAllStringSubmatch(memory, -1)
|
||||
|
||||
|
@ -31,6 +32,8 @@ func findAndExecuteInstructions(memory string) (res int) {
|
|||
}
|
||||
|
||||
func findAndExecuteEnabledInstructions(memory string) (res int) {
|
||||
// find all `mul()` and save numbers as MatchGroup 1 + 2
|
||||
// save `do()` and `dont()` in MatchGroup 0
|
||||
re := regexp.MustCompile(`mul\((\d{1,3}),(\d{1,3})\)|do\(\)|don't\(\)`)
|
||||
instructions := re.FindAllStringSubmatch(memory, -1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue