|  | @@ -52,22 +52,25 @@ func part2(lines []string) int {
 | 
											
												
													
														|  |  	multiply := true
 |  |  	multiply := true
 | 
											
												
													
														|  |  	re := regexp.MustCompile(`mul\(\d+,\d+\)`)
 |  |  	re := regexp.MustCompile(`mul\(\d+,\d+\)`)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -	var startIndex int
 |  | 
 | 
											
												
													
														|  |  	for _, line := range lines {
 |  |  	for _, line := range lines {
 | 
											
												
													
														|  | -		edge := len(line) - 1
 |  | 
 | 
											
												
													
														|  | -		endIndex := edge
 |  | 
 | 
											
												
													
														|  | 
 |  | +		var startIndex, endIndex int
 | 
											
												
													
														|  |  		reading := true
 |  |  		reading := true
 | 
											
												
													
														|  |  		for reading {
 |  |  		for reading {
 | 
											
												
													
														|  |  			if multiply {
 |  |  			if multiply {
 | 
											
												
													
														|  | -				index := strings.Index(line[startIndex:edge], "don't()")
 |  | 
 | 
											
												
													
														|  | 
 |  | +				index := strings.Index(line, "don't()")
 | 
											
												
													
														|  |  				multiply = false
 |  |  				multiply = false
 | 
											
												
													
														|  |  				if index == -1 {
 |  |  				if index == -1 {
 | 
											
												
													
														|  | -					endIndex = edge
 |  | 
 | 
											
												
													
														|  | 
 |  | +					endIndex = len(line)
 | 
											
												
													
														|  |  					reading = false
 |  |  					reading = false
 | 
											
												
													
														|  |  				} else {
 |  |  				} else {
 | 
											
												
													
														|  |  					endIndex = index
 |  |  					endIndex = index
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +				if startIndex > endIndex {
 | 
											
												
													
														|  | 
 |  | +					startIndex++
 | 
											
												
													
														|  | 
 |  | +					continue
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  				matches := re.FindAllString(line[startIndex:endIndex], -1)
 |  |  				matches := re.FindAllString(line[startIndex:endIndex], -1)
 | 
											
												
													
														|  |  				for _, match := range matches {
 |  |  				for _, match := range matches {
 | 
											
												
													
														|  |  					mul := make([]int, 2)
 |  |  					mul := make([]int, 2)
 | 
											
										
											
												
													
														|  | @@ -78,14 +81,17 @@ func part2(lines []string) int {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  					result += mul[0] * mul[1]
 |  |  					result += mul[0] * mul[1]
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +				line = line[endIndex:]
 | 
											
												
													
														|  | 
 |  | +				startIndex = 0
 | 
											
												
													
														|  |  			} else {
 |  |  			} else {
 | 
											
												
													
														|  | -				index := strings.Index(line[startIndex:edge], "do()")
 |  | 
 | 
											
												
													
														|  | 
 |  | +				index := strings.Index(line, "do()")
 | 
											
												
													
														|  |  				if index == -1 {
 |  |  				if index == -1 {
 | 
											
												
													
														|  | -					startIndex = 0
 |  | 
 | 
											
												
													
														|  |  					reading = false
 |  |  					reading = false
 | 
											
												
													
														|  |  				} else {
 |  |  				} else {
 | 
											
												
													
														|  |  					multiply = true
 |  |  					multiply = true
 | 
											
												
													
														|  | -					startIndex = index
 |  | 
 | 
											
												
													
														|  | 
 |  | +					startIndex = 0
 | 
											
												
													
														|  | 
 |  | +					line = line[index:]
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 |