mirror of
				https://github.com/tanishq-dubey/aoc2023.git
				synced 2025-10-30 21:37:12 -04:00 
			
		
		
		
	d3p2 done
This commit is contained in:
		
							
								
								
									
										20
									
								
								day3/main.py
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								day3/main.py
									
									
									
									
									
								
							| @@ -84,7 +84,6 @@ vals = {} | |||||||
|  |  | ||||||
| for x in range(len(parsed_data)): | for x in range(len(parsed_data)): | ||||||
|     for y in range(len(parsed_data[x])): |     for y in range(len(parsed_data[x])): | ||||||
|          |  | ||||||
|         if (not str.isnumeric(parsed_data[x][y])) and parsed_data[x][y] !=  BLANK: |         if (not str.isnumeric(parsed_data[x][y])) and parsed_data[x][y] !=  BLANK: | ||||||
|             n = gridCheck(parsed_data, x, y, BLANK) |             n = gridCheck(parsed_data, x, y, BLANK) | ||||||
|             #pp([n, x, y, parsed_data[x][y]]) |             #pp([n, x, y, parsed_data[x][y]]) | ||||||
| @@ -97,3 +96,22 @@ total = 0 | |||||||
| for _, v in vals.items(): | for _, v in vals.items(): | ||||||
|     total = total + v |     total = total + v | ||||||
| pp(total) | pp(total) | ||||||
|  |  | ||||||
|  | # Pt 2 | ||||||
|  | total = 0 | ||||||
|  |  | ||||||
|  | for x in range(len(parsed_data)): | ||||||
|  |     for y in range(len(parsed_data[x])): | ||||||
|  |         if (not str.isnumeric(parsed_data[x][y])) and parsed_data[x][y] !=  BLANK: | ||||||
|  |             n = gridCheck(parsed_data, x, y, BLANK) | ||||||
|  |             ratio = 1 | ||||||
|  |             tmp = {} | ||||||
|  |             for neighbor in n: | ||||||
|  |                 nn, pos = expandNumber(parsed_data, neighbor[0], neighbor[1]) | ||||||
|  |                 tmp[pos] = nn | ||||||
|  |             if len(tmp) == 2: | ||||||
|  |                 for _, v in tmp.items(): | ||||||
|  |                     ratio = v * ratio | ||||||
|  |                 total = total + ratio | ||||||
|  |  | ||||||
|  | pp(total) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user