From bc901b4d2d9b3670baf45a1f9ed0c0bf658dfd18 Mon Sep 17 00:00:00 2001 From: rak1507 <56049432+rak1507@users.noreply.github.com> Date: Sun, 5 Feb 2023 17:35:54 +0000 Subject: [PATCH] Update 15.md Add description for 15 --- aoc/2022/15.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/aoc/2022/15.md b/aoc/2022/15.md index cce4f66..f87ebcd 100644 --- a/aoc/2022/15.md +++ b/aoc/2022/15.md @@ -181,16 +181,60 @@ A very much faster solution starts from > the fact that any beacon will be adjacent to the perimeter of the region, so there are 4 straight lines that it could possibly pass through. Generate all the equations, and then the beacon will be at one of the intersections. ```q -`Sx`Sy`Bx`By set' flip {get @[x;where not x in "-0123456789";:;" "]}each inp; +`Sx`Sy`Bx`By set' flip {get @[x;where not x in "-0123456789";:;" "]}each read0 `15.txt; m: sum abs (Sx-Bx;Sy-By) / manhattan dists / part 1 -count except[;Bx where By=Y] distinct raze {$[y<0;();x-y-til 1+2*y]}'[Sx;m-abs Sy-Y] +count except[;Bx where By=Y] distinct raze {$[y<0;();x-y-til 1+2*y]}'[Sx;m-abs Sy-Y:2000000] / part 2 peri: raze 1 1 -1 -1,''(Sy-Sx+m+1; Sy-Sx-m+1; Sy+Sx+m+1; Sy+Sx-m+1) int: distinct raze peri {r:0-1%(%/)x-y; (r; sum x*r,1)}\:/: peri sum 4000000 1*floor first int where {all raze(x=floor x;0<=x;x<=LIM;m