day 14 puzzle 2
This commit is contained in:
		| @@ -6,11 +6,8 @@ | ||||
|   return calc.rem-euclid(v0 + dv * steps, max) | ||||
| } | ||||
|  | ||||
| #let solve(w: 0, h: 0, steps: 100, input) = { | ||||
|   assert(w != 0, message: "Width must be != 0") | ||||
|   assert(h != 0, message: "Height must be != 0") | ||||
|  | ||||
|   let bots = input.split("\n").map(b => { | ||||
| #let parse-input(input) = { | ||||
|   return input.split("\n").map(b => { | ||||
|     let m = b.match(regexp) | ||||
|     return ( | ||||
|       pos: ( | ||||
| @@ -23,6 +20,13 @@ | ||||
|       ) | ||||
|     ) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| #let solve(w: 0, h: 0, steps: 100, input) = { | ||||
|   assert(w != 0, message: "Width must be != 0") | ||||
|   assert(h != 0, message: "Height must be != 0") | ||||
|  | ||||
|   let bots = parse-input(input) | ||||
|  | ||||
|   let quadrants = ( | ||||
|     tl: 0, | ||||
|   | ||||
| @@ -0,0 +1,33 @@ | ||||
| #import "/src/utils.typ": * | ||||
| #import "@preview/cetz:0.3.1": canvas, draw | ||||
| #import "puzzle1.typ": parse-input, simulate | ||||
|  | ||||
| #let input = get-input(14) | ||||
| #let bots = parse-input(input) | ||||
| #let res = 8270 | ||||
| #let (width, height) = (101, 103) | ||||
| #let sim-x = simulate.with(max: width, steps: res) | ||||
| #let sim-y = simulate.with(max: height, steps: res) | ||||
| #let size = 0.1 | ||||
|  | ||||
| #figure( | ||||
|   canvas({ | ||||
|     draw.rect( | ||||
|       (0, 0), | ||||
|       (width * size, -height * size) | ||||
|     ) | ||||
|     for bot in bots { | ||||
|       let x = sim-x(bot.pos.x, bot.vel.x) | ||||
|       let y = sim-y(bot.pos.y, bot.vel.y) | ||||
|       draw.rect( | ||||
|         (x * size, -y * size), | ||||
|         ((x + 1) * size, -(y + 1) * size), | ||||
|         stroke: none, | ||||
|         fill: black | ||||
|       ) | ||||
|     } | ||||
|   }), | ||||
|   caption: "Christmas tree easter egg" | ||||
| ) | ||||
|  | ||||
| #show-result(res) | ||||
							
								
								
									
										
											BIN
										
									
								
								src/main.pdf
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/main.pdf
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user