|  | @@ -40,6 +40,10 @@ func symbolNear(lines []string, height int, width int, y int, start int, end int
 | 
											
												
													
														|  |  		i = start
 |  |  		i = start
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +	if end >= width {
 | 
											
												
													
														|  | 
 |  | +		end = width - 1
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  	canGoUp := y-1 >= 0
 |  |  	canGoUp := y-1 >= 0
 | 
											
												
													
														|  |  	canGoDown := y+1 < height
 |  |  	canGoDown := y+1 < height
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -64,15 +68,22 @@ func part1(lines []string) int {
 | 
											
												
													
														|  |  	var result int
 |  |  	var result int
 | 
											
												
													
														|  |  	height := len(lines)
 |  |  	height := len(lines)
 | 
											
												
													
														|  |  	width := len(lines[0])
 |  |  	width := len(lines[0])
 | 
											
												
													
														|  | 
 |  | +	edge := width - 1
 | 
											
												
													
														|  |  	for i := range lines {
 |  |  	for i := range lines {
 | 
											
												
													
														|  |  		var start, end int
 |  |  		var start, end int
 | 
											
												
													
														|  |  		gotNumber := false
 |  |  		gotNumber := false
 | 
											
												
													
														|  | 
 |  | +		tryRead := false
 | 
											
												
													
														|  |  		for j := range lines[i] {
 |  |  		for j := range lines[i] {
 | 
											
												
													
														|  |  			if isDigit(lines[i][j]) {
 |  |  			if isDigit(lines[i][j]) {
 | 
											
												
													
														|  |  				if !gotNumber {
 |  |  				if !gotNumber {
 | 
											
												
													
														|  |  					start = j
 |  |  					start = j
 | 
											
												
													
														|  |  					gotNumber = true
 |  |  					gotNumber = true
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +				if j == edge {
 | 
											
												
													
														|  | 
 |  | +					end = j + 1
 | 
											
												
													
														|  | 
 |  | +					tryRead = true
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  |  			} else {
 |  |  			} else {
 | 
											
												
													
														|  |  				if !gotNumber {
 |  |  				if !gotNumber {
 | 
											
												
													
														|  |  					continue
 |  |  					continue
 | 
											
										
											
												
													
														|  | @@ -80,6 +91,10 @@ func part1(lines []string) int {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  				end = j
 |  |  				end = j
 | 
											
												
													
														|  |  				gotNumber = false
 |  |  				gotNumber = false
 | 
											
												
													
														|  | 
 |  | +				tryRead = true
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if tryRead {
 | 
											
												
													
														|  |  				if symbolNear(lines, height, width, i, start, end) {
 |  |  				if symbolNear(lines, height, width, i, start, end) {
 | 
											
												
													
														|  |  					var d int
 |  |  					var d int
 | 
											
												
													
														|  |  					n, err := fmt.Sscanf(lines[i][start:end], "%d", &d)
 |  |  					n, err := fmt.Sscanf(lines[i][start:end], "%d", &d)
 | 
											
										
											
												
													
														|  | @@ -89,6 +104,8 @@ func part1(lines []string) int {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  					result += d
 |  |  					result += d
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +				tryRead = false
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		}
 |  |  		}
 |