diff --git a/src/day8/puzzle1.typ b/src/day8/puzzle1.typ index 0c8cc2b..7015c34 100644 --- a/src/day8/puzzle1.typ +++ b/src/day8/puzzle1.typ @@ -49,7 +49,7 @@ } } -#let visualize(input) = { +#let visualize(solve, input) = { let (grid, by-freq, antinodes) = solve(input, return-data: true) let w = grid.first().len() let h = grid.len() @@ -58,7 +58,7 @@ let n-freqs = freqs.len() let colors = gradient.linear(red, orange, yellow, green, aqua, blue, purple) - canvas(length: 1.75em, { + canvas(length: 1.85em, { for y in range(h) { for x in range(w) { draw.circle( @@ -94,5 +94,5 @@ 8, 1, solve, example: 14, - visualize: visualize + visualize: visualize.with(solve) ) \ No newline at end of file diff --git a/src/day8/puzzle2.typ b/src/day8/puzzle2.typ index 66bfcd1..5af0eea 100644 --- a/src/day8/puzzle2.typ +++ b/src/day8/puzzle2.typ @@ -1,4 +1,5 @@ #import "/src/utils.typ": * +#import "puzzle1.typ": visualize #let in-grid(w, h, x, y) = { return 0 <= x and x < w and 0 <= y and y < h @@ -27,7 +28,7 @@ return antinodes } -#let solve(input) = { +#let solve(input, return-data: false) = { let by-freq = (:) let antinodes = () @@ -55,11 +56,17 @@ } } - return antinodes.dedup().len() + antinodes = antinodes.dedup() + return if return-data { + (grid, by-freq, antinodes) + } else { + antinodes.len() + } } #show-puzzle( 8, 2, solve, - example: 34 + example: 34, + visualize: visualize.with(solve) ) \ No newline at end of file diff --git a/src/main.pdf b/src/main.pdf index 297e8fb..184d5bc 100644 Binary files a/src/main.pdf and b/src/main.pdf differ