| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -8,7 +8,9 @@ import ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"strings" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					func validgame(totalred, totalgreen, totalblue int, r io.Reader) bool { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					var replacer = strings.NewReplacer(",", " ", ";", " ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					func maxgame(r io.Reader) (red, green, blue int) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						scanner := bufio.NewScanner(r) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						scanner.Split(bufio.ScanWords) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -17,26 +19,26 @@ func validgame(totalred, totalgreen, totalblue int, r io.Reader) bool { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								break | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							num, _ := strconv.Atoi(scanner.Text()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							n, _ := strconv.Atoi(scanner.Text()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							scanner.Scan() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							switch scanner.Text() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							case "red": | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if num > totalred { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									return false | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if n > red { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									red = n | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							case "green": | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if num > totalgreen { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									return false | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if n > green { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									green = n | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							case "blue": | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if num > totalblue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									return false | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if n > blue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									blue = n | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return true | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					type day02 struct{} | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -48,14 +50,14 @@ func (d day02) solve1(r io.Reader) string { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							totalblue  = 14 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							gameSum    = 0 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							scanner    = bufio.NewScanner(r) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							replacer   = strings.NewReplacer(",", " ", ";", " ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						for gameN := 1; scanner.Scan(); gameN++ { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							line := scanner.Text() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_, game, _ := strings.Cut(line, ": ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							sr := strings.NewReader(replacer.Replace(game)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if validgame(totalred, totalgreen, totalblue, sr) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							red, green, blue := maxgame(sr) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if red < totalred && green < totalgreen && blue < totalblue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								gameSum += gameN | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -64,5 +66,18 @@ func (d day02) solve1(r io.Reader) string { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					func (d day02) solve2(r io.Reader) string { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return "" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						var ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							sum     = 0 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							scanner = bufio.NewScanner(r) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						for scanner.Scan() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							line := scanner.Text() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							_, game, _ := strings.Cut(line, ": ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							sr := strings.NewReader(replacer.Replace(game)) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							red, green, blue := maxgame(sr) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							sum += (red * green * blue) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						return fmt.Sprintf("%d", sum) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
					 | 
				
				 | 
				
					
  |